It there are many "what ifs" like in the posted article. You probably need another format like JSON (preferably) or XML.
So You Want to Write Your Own CSV code
61–70 of 127 posts
Re: So You Want to Write Your Own CSV code
#62Easy to write, hard to read. Perfect illustration of an emergent case of Postel's Law.
Re: So You Want to Write Your Own CSV code
#63Re: So You Want to Write Your Own CSV code
#64The most retard structure I've seen in a CSV file relates to the "What if the character separating fields is not a comma?". We get "CSV" files from Klarna, an invoicing company, with the payments they've processed for us. Because we're Danish and they are Swedish, it's not really weird that they would use comma as the decimal separator. So to compensate for having used the comma, they for some reason picks ", " ( tha…
I have an function that I usually use in projects that counts , and ; on each line to determine which one is most likly beeing used in the file.
The most annoying thing I have found in csv files is the escape sign I would like it to be \" but very often I see """ as the escape for "
Re: So You Want to Write Your Own CSV code
#65The most retard structure I've seen in a CSV file relates to the "What if the character separating fields is not a comma?". We get "CSV" files from Klarna, an invoicing company, with the payments they've processed for us. Because we're Danish and they are Swedish, it's not really weird that they would use comma as the decimal separator. So to compensate for having used the comma, they for some reason picks ", " ( tha…
In General Swedish csv files are separated with ; I have an function that I usually use in projects that counts , and ; on each line to determine which one is most likly beeing used in the file. The most annoying thing I have found in csv files is the escape sign I would like it to be \" but very often I see """ as the escape for "
Re: So You Want to Write Your Own CSV code
#66Re: So You Want to Write Your Own CSV code
#67CSV works for simple cases. It is trivial to parse, you shouldn't even need a library. It there are many "what ifs" like in the posted article. You probably need another format like JSON (preferably) or XML.
Re: So You Want to Write Your Own CSV code
#68Earlier quoted context omitted.
I would say use the parser included in your programming environment, but I spend way to long looking of the non existing CSV parser in .Net.
Not a single language I use on a routine basis includes a CSV parser in its standard library.
Re: So You Want to Write Your Own CSV code
#69Re: So You Want to Write Your Own CSV code
#70as the article mentions, CSV is not well defined. libraries are.. well, different. you'd spend as much time becoming familiar with one as you would writing a basic parser. commas don't delimit field entries? CSV -> comma separated values. new lines inside a field? i've never written a parser that would be foiled by this. could be an issue if you use a built-in tokeniser (e.g strtok, etc.). be aware. variable number o…
In general it's not about being smart enough (although for some complicated standards maybe it's true), but rather biting off more than you realize. Everything sounds simple before you find the edge case implementation issues and have to rework and rethink a bunch of hard issues that a dozen people have already thought through. Doing it yourself is on the table, but rarely the most efficient decision.