Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get csv file with quotation option #2

Open
marcosarmas opened this issue Jul 18, 2020 · 3 comments
Open

Get csv file with quotation option #2

marcosarmas opened this issue Jul 18, 2020 · 3 comments

Comments

@marcosarmas
Copy link

Hi,

I'm working with this client to download Discover data, but I'm having problems choosing a good delimiter, there is a way to quote the text fields?

thanks,

Marcos.

@andybouts
Copy link

I am having the same issue. When using the standard "|" as the delimiter, the "visit_details.csv" and "page_details.csv" are failing to import using the Viya based /SASDataExplorer and the error leads me to believe that some of the fields have a | int he field.

One way to get around this is as marcosarmas mentioned, which is to encapsulate the text fields in " so that, in this example, "b|ar" is not parsed into two fields:
|"foo"|"b|ar"|

Otherwise, unless I am missing something, the options are to use a multi-character delimiter such as |^| or find a character that's unique enough to be a delimiter.

Do you have other advice?

@andybouts
Copy link

Hi Marcos, I figured out a workaround yesterday. It seemed that every single special character that was a standard ASCII character was also in my dataset, so we used a multi-character delimiter to ensure we had good field boundaries (using the -cd parameter):
$ python discover.py -m detail -svn 4 -a yes -cd "|;|" -cf yes -st 2020-08-15T00 -et 2020-09-01T00

We later learned of a limitation in the application we were using to import the data, so we used sed to replace |;| with the CTRL-A special character equivalent of \x01

--- Request to the developers --- please include a parameter(s) to allow for quoting the field boundaries to account for the situation where a delimiter could exist inside the field value ... as I understand it, the you can pass an option (quote full or quote partial) to the standard:
csv.writer(…… quoting=csv.QUOTE_ALL)

@marcosarmas
Copy link
Author

Hi Andy,

Great solution! I go to try it!

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants