News for hackers. Stuff that matters.
Re:Friends don't let friends export to CSV by diogocp on Monday March 25, 2024 @09:21PM (#39823323)
> in the real world the spec is essentially "Can you import it to Excel?"

And the answer to that is always no. You will it think it's yes because it works for you, but when you send it to someone who has a different Excel version or simply different regional settings, it won't work. The recipient will first have to figure out what dialect you used to export.

Re:Friends don't let friends export to CSV by chaps on Monday March 25, 2024 @09:49PM (#39823482)
"Always no"? What. Really not sure what you mean here when you agree that the possibility of it working exists.

I get the sentiment -- when I request data through FOIA, I will almost always request it as "an excel format" because I know that I'll at least be able to import it. CSV is much less of a guarantee and will have issues -- missing quotes, wrong delimiters, inconsistent column counts, things like that. So requesting "an excel format" implies "make the best effort to give me something that will load in my excel, but without asking what version of excel I have". Removes a fair amount of hassle, especially when it took months to get the data. It also means that if they fuck up the columns by doing a conversion, you have some means of telling them that the data is simply wrong, rather than the data is hard to work with. It does mean dealing with [0-9]+GB sized excel files sometimes, though.

That all said, I prefer to share CSV files. Haven't had much of a problem with it and I can guarantee some consistency from my side. Like, the people I share files with aren't going to know what the hell a parquet file is. A CSV though? Just double click it if you're less technical, or open it up in less if you can use a terminal. It usually compresses well, despite what the author wrote.

Re:Friends don't let friends export to CSV by throwaway2037 on Tuesday March 26, 2024 @12:52AM (#39824364)

   > when I request data through FOIA
Fascinating. Can you share any details? Did you ever think to share some of your interesting finds here on HN as a submission?
Re:Friends don't let friends export to CSV by chaps on Tuesday March 26, 2024 @02:41AM (#39824838)
Re:Friends don't let friends export to CSV by chongli on Tuesday March 26, 2024 @06:01AM (#39825965)
That was a really fascinating story! Thanks for sharing.
Re:Friends don't let friends export to CSV by r-w on Tuesday March 26, 2024 @09:16AM (#39827423)
Wow, what a treasure trove you’ve got there! I’ve subscribed via RSS, in case anything else comes down the pipe :)
Re:Friends don't let friends export to CSV by chaps on Wednesday March 27, 2024 @01:12AM (#39835867)
Thank you! Hopefully by the end of the year but these things can get, strange.
Re:Friends don't let friends export to CSV by Stranger43 on Tuesday March 26, 2024 @01:51AM (#39824607)
At this point i suspect excel is as dangerous as powerpoint to the quest for sharing and improving human knowledge, in that it gives the illusion of allowing people to analyze data but not the tools to make sure they get their data and model lined up correctly.
Re:Friends don't let friends export to CSV by geraldhh on Tuesday March 26, 2024 @05:43AM (#39825860)
otoh it could be instrumental precisely because it is flexible and doesn't require a lot of forethought
Re:Friends don't let friends export to CSV by goatlover on Tuesday March 26, 2024 @02:08AM (#39824685)
If the answer was always no, importing CSVs to Excel wouldn't be an expectation or widely used.
Re:Friends don't let friends export to CSV by kibwen on Tuesday March 26, 2024 @07:04AM (#39826367)
The answer is "always no" because the question is inherently underspecified, precisely because importing things into Excel is more complicated and context-dependent than it appears on the surface.
Re:Friends don't let friends export to CSV by Pikamander2 on Tuesday March 26, 2024 @03:48AM (#39825143)
I've been amazed by how much LibreOffice is at importing CSVs in a sane manner than Excel. Its CSV import prompt is nothing short of the gold standard and puts Excel to shame.

Also, even if the CSV format is completely valid, Excel will still find a way to misinterpret some of your cells in baffling ways, destroying the original data in the process if you don't notice it in time.

Re:Friends don't let friends export to CSV by prox on Tuesday March 26, 2024 @04:49AM (#39825522)
Heck yes, LibreOffice shines when it comes to that. Excel always threw me curveballs a lot.
Re:Friends don't let friends export to CSV by wiz21c on Tuesday March 26, 2024 @05:13AM (#39825683)
Yeah, I can complain about LO in many ways, but the way it opens CSV is much better than Excel. It was developed by a dev, that's for sure.
Re:Friends don't let friends export to CSV by nuc1e0n on Tuesday March 26, 2024 @06:31PM (#39833589)
The root cause of a lot of problems is that Excel's CSV import is garbage.

Someone should write a simple utility modelled on LibreOffice's CSV import dialog that reads in a CSV file and outputs its content as an XLSX file with all the cells formatted as text. Being as how XLSX files are just XML text in a renamed ZIP file and CSV is a very simple format such a project could be written over a weekend.

Network admins could then create a group policy to reassign the CSV file extension to open with the utility instead of Excel. I guess the utility could automatically open the generated XLSX in Excel as well.

This would fix so many data corruption issues across the whole world.

Microsoft themselves could even do this as a powertoy.

Re:Friends don't let friends export to CSV by smcin on Tuesday March 26, 2024 @09:28AM (#39827569)
Yes the LibreOffice CSV import dialog showing you a what-if preview of what you'd get as you play with different settings, is pure amazing.
Re:Friends don't let friends export to CSV by Freak_NL on Tuesday March 26, 2024 @03:49AM (#39825146)
Oh absolutely. Don't forget about the giant mess Microsoft made in countries like the Netherlands, where Excel will refuse to automatically open comma-separated values files (you know, CSV), unless the separator is a semicolon — because someone in the past thought that was how the Dutch did it.

You want people to be able to open your nice and sensible CSV files in Excel? First figure out which arcane locale specific settings you need, then generate those monstrosities and annoy anyone who genuinely expected Unicode comma-separated values.

My solution was to just write a generic spreadsheet writer component in our API and have it generate CSV (normal, comma-separated, UTF-8), XLSX, or ODS. Anyone using Excel just grabs the XLSX output. Generating XLSX and ODS was just a matter of saving a minimal example file for each and figuring out where to write cells and rows. No extra library needed (both file formats are just zipped up XML files), and everybody is happy.

Re:Friends don't let friends export to CSV by roelschroeven on Tuesday March 26, 2024 @06:24AM (#39826096)
Many countries use the comma as decimal separator, and Microsoft in its infinite wisdom thinks that data interchange formats should follow regional formatting settings (that's unbelievably stupid; I'll never understand how such an enormous error not only came to be, but was never corrected). That makes the comma unusable as column separator in those countries for exchange of numerical data.
Re:Friends don't let friends export to CSV by wouldbecouldbe on Tuesday March 26, 2024 @08:22AM (#39826952)
US users have the same in my experience. I've had multiple clients complain the exports are broken, because Excel only imports them (perfectly) but doesn't allow to open them. I thought it was their way of forcing excel files. Iphone & Google Drive no issues.
Re:Friends don't let friends export to CSV by alexvoda on Tuesday March 26, 2024 @07:54AM (#39826727)
On the other hand you can now use Power Query to import perquet data into Excel.
Re:Friends don't let friends export to CSV by resource_waste on Tuesday March 26, 2024 @11:12AM (#39828924)
Whatever situation got you into the "Power" universe was bad.

Warning you about M$, you will soon be an enterprise dev.

Re:Friends don't let friends export to CSV by alexvoda on Wednesday March 27, 2024 @05:02AM (#39836888)
I am not in that universe, on the contrary I try to stay as far away as possible. And I agree with you. However I think the everything-done-in-OLD-Excel universe is worse. Some people will be terminally stuck in Excel but at least they can use new Excel capabilities instead of being stuck with the Excel of 20 years ago.

So why remain stuck importing CSVs into Excel when you can use Power Query to import Parquet. Why remain stuck using VBA in Excel when you can use Python in Excel.

I do not think an Excel user can be convinced to move to things like Jupyter, R, databases, etc. since they won't even make the jump to Access but maybe they can be convinced to use modern features of Excel.

Re:Friends don't let friends export to CSV by resource_waste on Wednesday March 27, 2024 @03:17PM (#39843405)
Sorry man, I can't think of a case where I'd import a CSV into excel, but have the skill level to use powerquery and import parquet.

Like, if you are going to use power query, why not just python? At least this way you arent going to get nailed into a legacy hellhole.

Re:Friends don't let friends export to CSV by pif on Tuesday March 26, 2024 @08:09AM (#39826835)
>> in the real world the spec is essentially "Can you import it to Excel?"

> And the answer to that is always no.

Sorry, you are wrong! You are confusing "No" and "Yes, after a quick setup at most".

Re:Friends don't let friends export to CSV by braiamp on Tuesday March 26, 2024 @08:14AM (#39826876)
Oh oh oh, I have a story about a quick setup. Sent a csv file to someone in the same org. Guy said that it was not opening. Wanted me to come to their office to see. I told them that IT support should fix it, since I can't, and every machine on my OU could read it. I was the bad guy. Yeah, quick setup my ass. Users can't be arsed to understand that their setup isn't properly configured.
Re:Friends don't let friends export to CSV by mcv on Tuesday March 26, 2024 @09:14AM (#39827405)
Yeah, I definitely prefer CSV over Excel. Excel messes with your data. CSV is what it is. Sure, you may not know exactly what that is, and plenty of times I've had to figure out manually how to handle a specific CSV export, but once I've figured that out, it will work. With Excel, there's always the risk that a new value for a string field could also be interpreted as a date.