Read CSV file on Windows 7, 64 bit

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Read CSV file on Windows 7, 64 bit

aradwan
Hi,
I am really a beginner with Ocatve.
I have a CSV file with one column, 8760 rows. I need to load this file to octave. I tried a lot with csvread but I couldn't load the file.
I don't know where should I put the original csv file to be read.
I am using Octave3.4.3
Please help with details.....

Thanks
Amr
Reply | Threaded
Open this post in threaded view
|

RE: Read CSV file on Windows 7, 64 bit

Allen.Windhorn-2
Aradwan,

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of aradwan

> I have a CSV file with one column, 8760 rows. I need to load
> this file to octave. I tried a lot with csvread but I couldn't
> load the file. I don't know where should I put the original
> csv file to be read.

I have the same setup.  You can put the file in a directory in
your path (type "path" at the prompt to see what is in it).
[Caveat: this didn't seem to work for me.  Maybe only for
execution of a file.] Or you can give a full path to the file.
Or you can change directory and then read the file.

Here is what I did:

octave-3.2.4.exe:6> addpath c:/users/windhoal/Documents/m
octave-3.2.4.exe:7> savepath
warning: savepath: current path saved to ~\.octaverc
octave-3.2.4.exe:8> B = csvread("csvfile.csv")
error: dlmread: unable to open file `csvfile.csv'
error: called from:
error:   C:\Octave\...\csvread.m at line 27, column 5
octave-3.2.4.exe:9> help cd
`cd' is a built-in function

 -- Command: cd dir
 -- Command: chdir dir
     Change the current working directory to DIR.  If DIR is omitted,
     the current directory is changed to the user's home directory.
     For example,

          cd ~/octave

     Changes the current working directory to `~/octave'.  If the
     directory does not exist, an error message is printed and the
     working directory is not changed.

     See also: mkdir, rmdir, dir ...

octave-3.2.4.exe:10> cd c:/users/windhoal/Documents/m
octave-3.2.4.exe:11> B = csvread("csvfile.csv")
B =

  1.2340e+002  1.1600e+001
  9.5992e+003  5.5830e-001
  7.6500e+000  2.1990e+001

octave-3.2.4.exe:12> C =
csvread("c:/users/windhoal/Documents/m/csvfile.csv")
C =

  1.2340e+002  1.1600e+001
  9.5992e+003  5.5830e-001
  7.6500e+000  2.1990e+001

Note that the file path is written with forward slashes.  If you
use backslashes you may have to double them.

Regards,
Allen
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave