JuliaData / CSV.jl

Utility library for working with CSV and other delimited files in the Julia programming language
https://csv.juliadata.org/
Other
459 stars 141 forks source link

CSV.write somehow cannot write file with name `con.csv` in Windows?! #1111

Open mzy2240 opened 10 months ago

mzy2240 commented 10 months ago

MWE:

using DataFrames, CSV

df = DataFrame(:a => [1,2])
CSV.write("C:/Users/zmao/Desktop/test/con.csv", df)

Julia version: 1.9.2 Windows version: Windows 10 Enterprise 22H2

quinnj commented 10 months ago

Can you share the error you're seeing?

mzy2240 commented 10 months ago

No error but the generated file does not exist

mzy2240 commented 10 months ago

Ok this is the reason: https://stackoverflow.com/questions/59345760/os-path-exists-gives-false-positive-for-files-named-con-csv-on-windows

mzy2240 commented 10 months ago

then why there is no error?

hhaensel commented 9 months ago

These names behave like files, i.e. they support open, write and read, but they do different things than you expect, see e.g. https://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx.

There is simply no way to generate a file on Win-Os that with the basename "con". Renaming also doesn't work. If you want to make sure that such name is not used, check beforehand, e.g.

if lowercase(splitext(basename(filename))[1]) == "con"
  @info "Filename '$(uppercase(basename(filename)))' not supported under Windows"
end