Often encounter CSV and other related files, which have Chinese characters, very naturally, we will think of READCSV,READDLM and other built-in functions.
However, these are not processed and will report related character errors.
Today, the main point is to discuss the problem in this respect.
Here is a CSV file, flow.csv. Format is as follows:
One, loading Stringencodings library
Pkg.add ("Stringencodings")
Ii. Conduct of relevant processing
Using Stringencodings;
Path = "C:\\users\\desktop\\flow.csv";
data = open (path, enc "GB18030", "R") do stream
ReadString (stream);
End
If:
For I in the Data
print (i) End
Output:
But we know that data is a character vector of characters Fu Yi that needs to be parsed into the corresponding CSV format.
Let's see, specifically how, for convenience, we only look at the first 9 lines:
for (I,d) in enumerate (data)
if i<10
println ("I: $i, data content: $d")
end
Output:
From the above, you can see that the Chinese characters are read out, but we get a character vector with ",", "\ R" and so on, which is not our ultimate goal.
Third, how to become a CSV format.
See the Ultimate kill device:
Data =open (readcsv, PATH, enc "GB18030"); # array{any,2}
Such data is the kind of readcsv format we need.