简体   繁体   中英

Read images from a csv file with Octave

I want to read the training.csv file with Octave for the Kaggle competition . The file contains 16 fields. First 15 are the coordinates of keypoints. The 16th is is the image, which is 9216 numbers (0 to 255) separated by space.

Tried, but with no luck the followings:

 - data = csvread('training.csv'); 

 - data = dlmread('training.csv', ',');

 - [l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15, image] =
   textread("training.csv", "%f %f %f %f %f %f %f %f %f %f %f %f %f %f
   %f %s", "delimiter", ",", "endofline", "\n", "headerlines", 1);

Note:

Thanks,

This post contributed greatly to figure this out. The key is to:

  • Remove the header row
  • Replace the ",," (double commas) with "0"
  • Replace "," (single comma) with " " (space)
  • The code to read the file

    fn = 'training_space.txt'; M = dlmread(fn);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM