Tag Info

New answers tagged

3

Possible cause: f = OpenWrite["test.csv"]; WriteString[f, "1,2,3\n\n4,5,6\n"]; Close[f]; FilePrint["test.csv"] Through[{Length, MatrixForm}@Import["test.csv", "Lines"]] Through[{Length, MatrixForm}@ReadList["test.csv", "Record"]] Readlist doesn't count a blank line (double line ending) as a "record" while Import does You can fix this with ...


2

For simply saving numbers or lists to file, I personally prefer to use Put/>> and PutAppend/>>> to store data, and ReadList to retrieve it. For instance: (# >>> "file.dat") & /@ {1,2,3}; ReadList["file.dat"] (* {1,2,3} *) (# >>> "file.dat") & /@ {1,2,3,4,5}; ReadList["file.dat"] (* {1,2,3,1,2,3,4,5} *) You could ...


5

Open the file with OpenAppend not OpenWrite. Any Writes will then append to the file not overwrite.


2

Adding directory to the beginning of the paclet search path One thing to note is that paclet search path is used only when getting files using a path with ordinary path separator. When getting packages using path with elements separated by context separator ` paclet search path is not used. To add a directory to beginning of paclet search path in ...


2

Put seems to treat the argument as literal and not evaluate it. i.e. it takes the argument filename as the actual filename and not its value. In Mathematica talk, this is called Holding its arguments. Just do this: expression >> Evaluate@filename Should work. Worked for me. Full example: SetDirectory[NotebookDirectory[]]; somenumber = 10; ...


2

When I repeat the steps in the original post, I occasionally get the behavior mentioned, but not every time. Below is one way you can get the behavior every time. Input style Open a new notebook Type "hello" into an input cell (style is "input" by default) Highlight "hello" and copy/paste into Notepad In Notepad you will see simply "hello" Change to ...



Top 50 recent answers are included