PDA

View Full Version : Clean open/save of .csv files?


alcimedes
2011-03-02, 20:37
I've been trying to export then re-import some data that is only exported as .csv files.

However, Excel (of course) and Open Office both appear to pollute the file when I save them, although the re-upload of the data throws errors at me, I have no way to find out what they're actually from. (vendor's site, I don't expect worthwhile answers from them)

So basically I'm wondering if there's something that will allow me to open up a .csv based file with a basic spreadsheet layout (since some of the fields have huge amounts of content) but will save it "cleanly".

I figure programmers may have run into some good text based tools, or a way to use the tools I have a bit better.

Brad
2011-03-03, 01:00
Excel usually throws carriage returns in CSVs upon export; that's typically what "pollutes" them. Further, I believe the Windows version *always* exports as Latin-1, but I'd have to double check that, and it's rarely a problem for most users. Further still, I believe that by default, Excel exports content "as its displayed", meaning if you have 1234567890 in a field, it'll probably default to displaying and exporting that as 1.23456789e8 instead.

In my experience, the carriage return is the only really offensive piece, but most off-the-shelf CVS parsers automatically handle those. I think Open Office (or at least the NeoOffice port I've used) generally does much better at exporting to CSV than Excel. I don't think I've had any of those problems with it.

Without taking a look at a sample from the file, it'd be pretty hard to make recommendations on how to clean/fix it. Maybe you can "sanitize" some data for us and attach a few rows?

alcimedes
2011-03-03, 10:06
Ah, that is helpful though. I'm going to try NeoOffice, I had forgotten about that. I'd used it well in the past, but hadn't installed it yet on the new box. If it keeps giving me trouble I'll post some of the actual values here.