February 16, 2003

I got back to work on the CSV reader component yesterday since the client has been having problems with embedded carriage returns in a CSV record. I had originally thought that a CSV record was a single line in the CSV file but turns out that I was wrong since in the case of embedded carriage returns, you’ll have multiple lines for the same record. However, since a column with an embedded carriage return gets enclosed in quotes, I modified my code so that if the component finds a column with an open ended quote, it reads the next line and the next line and the next line till it finds the closing quote. This should take care of embedded carriage returns but I’m not really sure what other problems this might have initiated. Plus, I don’t think I still have provided for one extreme case – what if a column has both quotes and carriage returns embedded in it? CSV usually doubles the quotes to indicate that a quote is there and I handle that fine and I do handle embedded carriage returns fine too but what if you have the opening quote for a column, then doubled quotes to indicate an actual quote in the data and then a carriage return and the closing quote for the column in the next line? I don’t think my code catches that … yet … So I have to go back to the code again today :p

I also want to get to work on Blog and fix a few bugs including the one which does not add an entry for the earliest range in the archive table of contents. I don’t know how long that bug has been there but quite a few people have been mentioning it recently and so it’s high time I did something about that. Plus, it looks as if the password encoding bug is more prevalent than I thought too. So that needs to be fixed as well. I still have done nothing with my installation of B2 to get BlogMan support for B2 finalized. There just is too much to be done …

Tags: General
Posted by Fahim at 7:13 am   Comments (5)

5 Responses to

Subscribe to comments with RSS

#1
Gravatar Image
DeViLbOi 15 February 2003 at 6:15 pm

CSV’s are supposed to be single lines. Maybe instead of going about it the way that you are you should remove CR until you get to your line limit for your specified data. It would at least catch all of that problem…espeically if you give a fudge range of 5 characters or so.

#2
Gravatar Image
Fahim 16 February 2003 at 3:58 pm

Actually, while most CSV files *are* single lined, I don’t think they *have* to be so. Because I loaded a CSV file with embedded carriage returns into Excel just fine. And the problem with removing carriage returns is that it disturbs the original data and since what I’m coding is a component to be plugged into other systems, I can’t do that – I have to return the data just as it is and that’s what I’ve opted to do :p

#3
Gravatar Image
DeViLbOi 16 February 2003 at 4:57 pm

So read the first x number of characters into a string and parse the string completely.

#4
Gravatar Image
Fahim 16 February 2003 at 5:15 pm

Umm … not sure what that would achieve as opposed to my current method of reading a whole line at a time? :p

#5
Gravatar Image
DeViLbOi 18 February 2003 at 6:57 pm

because you would read through the end of line. so lets say you have a CSV “line” which is 300 characters long but had 4 new lines in it. You read your 300 characters and parse out your fields from there.

Leave a response

:mrgreen: :neutral: :twisted: :shock: :smile: :???: :cool: :evil: :grin: :oops: :razz: :roll: :wink: :cry: :eek: :lol: :mad: :sad: