I have a list that contains German characters and I write to csv file with fast-csv and gives me different characters.
import { writeToPath } from "fast-csv";
const data = [
{
"name": "Ästhetik Zahnarzt Hamburg City Z-24 Mö 17 / Dr. P. Michaelis, Dr. C. Khorram",
"street_number": "Speersort 8",
"zip_location": "20095 Hamburg, City Innenstadt",
"phone": "040 34 45 44",
"website": "http://www.z-24.de",
"area": "Branche: Zahnärzte"
}
]
writeToPath("tmp.csv", data, { headers: true })
.on("error", (err) => console.error(err))
.on("finish", () => console.log("Done writing."));
output is this: screenshot of output data
Ästhetik Zahnarzt Hamburg City Z-24 Mö 17 / Dr. P. Michaelis, Dr. C. Khorram | ... | Branche: Zahnärzte
CodePudding user response:
This is the Excel issue with guessing a CSV encoding.
Just indicate the option writeBOM
equals to true
, that way Excel can guess that the encoding is UTF-8.
The most reliable way is to write to XLSX-file directly to avoid such encoding issues.