1
$\begingroup$

My goal is to export a list of numbers into a file, with a comma between each value. Executing the following commands seems to produce a file with a new line between each entry.

v = {1.1, 2.2, 3.3};
SetDirectory@NotebookDirectory[]; 
Export["v.csv", v, "csv"];

When I open the file with notepad, what I see is
1.1
2.2
3.3

What I would like to see is comma separated values, like the following:
1.1, 2.2, 3.3

Recommendations? Thanks.

$\endgroup$
4
$\begingroup$

Because your expression v is a vector, it's being interpreted as one line per number.

The following gives your desired result.

Export["v.csv", {v}, "csv"]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.