Message Boards Message Boards

0
|
8092 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Import a csv file where separators are semicolon";" instead comma ","

In some countries the file.csv elements are separated by semicolom ";" instead comma "," How I can convert to the standar csv format?

cylcsv = Import[
   "https://analisis.datosabiertos.jcyl.es/explore/dataset/situacion-\
de-hospitalizados-por-coronavirus-en-castilla-y-leon/download/?format=\
csv&timezone=Europe/Madrid&lang=es&use_labels_for_header=true&csv_\
separator=%3B", "csv"];

I have tried Replace[cylcsv /. {";" -> ","}] but it doesn´t work

I found a method for this specific file by I think there is a general method.

Thank you Guillermo

3 Replies

How about:

SemanticImport["https://analisis.datosabiertos.jcyl.es/explore/\
dataset/situacion-de-hospitalizados-por-coronavirus-en-castilla-y-\
leon/download/?format=csv&timezone=Europe/Madrid&lang=es&use_labels_\
for_header=true&csv_separator=%3B"]
POSTED BY: Henrik Schachner

Just be sure to also set "CurrencyTokens" -> None, otherwise there can be bad surprises:

In[103]:= ImportString[
 "1a;23
 1b;56
 1c;78", "Table", "FieldSeparators" -> {";"}]

Out[103]= {{"1a", 23}, {"1b", 56}, {1, 78}}

Oops, where did the c go from 1c?

POSTED BY: Szabolcs Horvát

I find that this way works:

Import["https://analisis.datosabiertos.jcyl.es/explore/dataset/\
situacion-de-hospitalizados-por-coronavirus-en-castilla-y-leon/\
download/?format=csv&timezone=Europe/Madrid&lang=es&use_labels_for_\
header=true&csv_separator=%3B", "Table", "FieldSeparators" -> ";"]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract