-1

Quite new to Scilab so struggling a bit with this, I have data imported from an oscilloscope as a csv file, I need to manipulate this data so I'm importing it with csvRead() but when I do this it is treating the 3 columns of my data as 1 column so I cant index it to use specific columns. And I need these to be separate. I've noticed that if I open the data in excel first & save it then the csvRead function does separate them into problems but the issue is I won't be able to open each data sheet in excel and save it each time on a large processing scale so I need a solution where it can open the file directly and see the separate columns rather than treating them as one column. I feel like there is a way using python to open the csv file in excel and then save and close it to then have csvRead to work but I have no idea how to implement this within scilab. If there is a fix to have the columns separate id appreciate that

my code is:

data = csvRead(filePath, ascii(9), ".", "string", [], [], [3 1 1202, 3]);
sequence = data(3:$, 1);
disp(sequence);

with my data this just shows the 3 columns as 1, anyone know a fix for them separate, idk if my parameters in csvRead are correct. I don't know if the ascii is needed or not either, when I use [] instead of ascii it says csvRead cannot read the file.

3
  • are you sure that your columns are separated by tabulations (ascii(9)) ? Commented Jul 10, 2024 at 15:48
  • im pretty sure csv is done by commas, but when i changed it to commas it still wouldnt separate it, and ascii(9) worked once i had opened and saved the csv in excel, but i need it to work without opening it in excel, any idea? thankyou! Commented Jul 11, 2024 at 15:59
  • Can you share your file, or just a subset ? scilab.discourse.group is a better place to achieve this. Commented Jul 12, 2024 at 6:34

1 Answer 1

0

If csvRead fails, kind of workaround may be to open your file as a standard text file and use mgetl and string operations line by line to separate the values. E.g.:

[fd,err] = mopen("c:\Scilab\test.csv","r");
txt = mgetl(fd);
close(fd);  //don't forget to close, otherwise Scilab can not reopen at next run

Then iterate through txt and you may use strtok to separate the fields and use strtod to convert the fields to numbers.

(If you find the answer useful, please do not forget to accept it, so others will see that your problem is solved.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.