Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.3K Views
|
4 Replies
|
1 Total Like
View groups...
Share
Share this post:

Confusion when exporting TSV file within a zip file if it's called CSV

Posted 2 years ago

Hi There,

The below is a little confusing - to clarify, I have a zip file with a TSV file in it. The TSV file ends in CSV where it should probably end in TSV.

I'm playing with GDELT data and want to do a bulk insert of file data into a SQL database. To do this I'm exporting a CSV file that is inside a zip file (supplied by GDELT). I have included one of these files, just rename the attached file to "20230101.export.CSV.zip".

I use this code to extract the TSV file from the zip file so I can use it in a bulk insert query (the TSV file ends in CSV where it should probably end in TSV):

Export["20230101.export.CSV",  Import[
   "20230101.export.CSV.zip", "20230101.export.CSV"] , "TSV"];

In the resulting file, each row is now enclosed by a " at each end (and the bulk insert fails since the file is not properly formatted).

If I rename the file within the zip file to "20230101.export.TSV" and export it using similar code it works properly and does not enclose each line with "".

Firstly, is this a bug? I would have expected Mathematica to export this properly since I added "TSV" in the export statement.

Since the files (inside the zip files) that are supplied have a slightly misleading "CSV" filetype ending (even though they are really TSV files), I am kind of stuck with this naming convention. Any suggestions on how I can get a properly formatted TSV file that I can use for bulk inserts?

Regards,
Sean.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard
Be respectful. Review our Community Guidelines to understand your role and responsibilities. Community Terms of Use