TASdvlper has asked for the wisdom of the Perl Monks concerning the following question:
Been a long time since I've been here, but I'm encountering a problem I need some assistance. Hopefully it's something easy, but I just can't see to get the code to work how I want it too.
So, I have this csv file that I want to parse. but the problem is, the person who was updating the spreadsheet put "newlines" in the cells (using alt+return I believe). So, as you can imagine, when I'm trying to parse the file, one record maybe contain several lines in the file.
What I would like to do is replace the new lines (or returns) with
so when I update to our database, and view with a browser, the format is preserves. I'm doing the replacement with $_ =~ s/(\r+|\n+)/<br>/g;. Which is working, but it's putting
in places that I don't want.
Example,
1. The first line in the csv file is each of the column names, I don't need
there.
2. The start of each new records begins with a "TC-" so I don't need a
at the very end of that record either. Again, the record may be several lines (it varies), until the next "TC-" is found.
Any thoughts ???
Thanks all !!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing a CSV file in a unique way
by Fletch (Bishop) on Oct 11, 2006 at 17:49 UTC | |
|
Re: Parsing a CSV file in a unique way
by blue_cowdawg (Monsignor) on Oct 11, 2006 at 17:49 UTC | |
|
Re: Parsing a CSV file in a unique way
by shmem (Chancellor) on Oct 11, 2006 at 18:10 UTC | |
by herveus (Prior) on Oct 11, 2006 at 19:19 UTC | |
by shmem (Chancellor) on Oct 12, 2006 at 05:30 UTC |