Skip to content

Not quoting strings automatically when required #1153

@TimG1964

Description

@TimG1964

See this discussion on Discourse for more details.

I can read a CSV file from an external source that contains the string:

"This award from the Export Development Fund will enhance the export opportunities for British films where they have been selected to appear at important international film festivals.\r"

(note the trailing \r)

CSV.file() reads this field into a DataFrame just fine.

If I subsequently write the DataFrame to another csv file, CSV.write() does not automatically quote the field, and this results in an invalid csv file.

Simple MWE Caution: the file that will be downloaded is over 250MB in size.
using CSV, DataFrames, Dates, HTTP

const url = raw"https://nationallottery.dcms.gov.uk/api/v1/grants/csv-export/"
const dataloc = [data store location]
const n = now()
const outfile = (string(Dates.year(n)) * lpad(string(Dates.month(n)), 2, '0') * lpad(string(Dates.day(n)), 2, '0') * " - DCMS grants.csv")
http_response = HTTP.get(url)

dcms = DataFrame(CSV.File(http_response.body, ntasks=1))


CSV.write(joinpath(dataloc, outfile), dcms)

CSV read will not read this newly written csv file correctly.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions