Reading data from GAUSS data (.dat) file

Hi there,

I converted a .csv file into a GAUSS data file (.dat) using ATOG. I was careful enough to remove missing observations and rows/columns with string values and there were no conversion errors.

Now I'm trying to read data from the ".dat" file into GAUSS and it just seems incredibly convoluted.

Here is what I have so far:

dataset_filename = "my_data.dat";
dataset_handle = dataopen(dataset_filename,"read");
nobs = rowsf(dataset_handle);
dataset = readr(dataset_handle,nobs);

This works, but is this the easiest way to store all of the rows and columns saved in the ".dat" file into a variable called "dataset"? Or am I just not seeing an obvious answer?

Thanks!

1 Answer



0



accepted

You can load all of the rows and columns of a GAUSS dataset by just passing your dataset name to the loadd function like this:

// Load all rows and columns from 'my_data.dat'
dataset = loadd("my_data.dat");

You might also like to know that you can also read tabular CSV files with the loadd function. For example, let's say you have a file named players.csv which looks like this:

"height","weight"
68,221
79,268
74,195

then you could load all the data with loadd like this:

p = loadd("players.csv");

and then p would contain:

68,221
79,268
74,195

Alternatively, you could use the csvReadM command to load the CSV data into a GAUSS matrix like this:

// Load all data starting at row 2
// from 'players.csv'
p2 = csvReadM("players.csv", 2);

aptech

1,773

Your Answer

1 Answer

0
accepted

You can load all of the rows and columns of a GAUSS dataset by just passing your dataset name to the loadd function like this:

// Load all rows and columns from 'my_data.dat'
dataset = loadd("my_data.dat");

You might also like to know that you can also read tabular CSV files with the loadd function. For example, let's say you have a file named players.csv which looks like this:

"height","weight"
68,221
79,268
74,195

then you could load all the data with loadd like this:

p = loadd("players.csv");

and then p would contain:

68,221
79,268
74,195

Alternatively, you could use the csvReadM command to load the CSV data into a GAUSS matrix like this:

// Load all data starting at row 2
// from 'players.csv'
p2 = csvReadM("players.csv", 2);


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy