Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm having trouble following your statement of the problem. After showing samples of the file data, you said:
If an item from file1 is in-stock, I need to update the field to the left of the size(SM,MD,LG,XL) to zero in file2.
Okay, this seems to mean that if a line in file1 starts with a non-zero value, some corresponding slot in file2 should be set to zero. But then you add "desired output should be:"
128,1,Download,0,,TEXT,2,Size,2,,SM,3,0,MD,4,,LG,5,,XL
But, the only difference between this "desired output" and the sample data for file2 is that a couple zeros in the original record have been removed, leaving empty fields next to the sizes that were apparently "out of stock" in file1.

You didn't say anything above about wanting to delete field contents for "out of stock sizes", and in this example, your stated goal of setting a field to zero looks like a no-op -- the field to the left of "MD" was already zero in the original file2 data, so there should be nothing to do.

What do you really want?


In reply to Re: Parsing and modifying CSV files by graff
in thread Parsing and modifying CSV files by ch1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-03-28 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found