Readall stops because of non-existing data, Can I skip these?
Hi y’all,
When I run my code I get an error:
Error using matlab.io.datastore.TabularDatastore/readall (line 196)
Unable to parse a "Numeric" field when reading row 39898, field 7.
Actual Text: "N,07121.27550,W,2,28,0.9,0.79,M,,,5,0131*01"
Expected: A number or literal "NaN", "Inf". (possibly signed, case insensitive
Is there a way to have the readall function skip these ,,, non-existing values in my data?
Code:
function [] = each_day_table(folder_referenced, output_folder_location)
dimention = size(folder_referenced) ;
for i = 1:dimention(2)
datastore_result = datastore(folder_referenced(i)) ;
original_data = readall(datastore_result) ;
new_table = new_table_useful_data(original_data) ;
[~, name, ext] = fileparts(folder_referenced(i)) ;
output_filename = fullfile(output_folder_location, "new_" + name + ext) ;
writetable(new_table, output_filename)
end
folder_with_files = dir(input_folder_location) ; % define directory where files are
filenames = fullfile({folder_with_files.folder}, {folder_with_files.name}) ; % access file path and name information
csvFiles = endsWith(filenames, ‘.csv’) ; % use logi → determining which values end in .csv (fullfile provides axtra info we don’t want)
filenames = filenames(csvFiles) ; % create cell array with all file names
each_day_table(filenames, output_folder_location) ; % applies all the functions to the files
I’ve attached a ference file.Hi y’all,
When I run my code I get an error:
Error using matlab.io.datastore.TabularDatastore/readall (line 196)
Unable to parse a "Numeric" field when reading row 39898, field 7.
Actual Text: "N,07121.27550,W,2,28,0.9,0.79,M,,,5,0131*01"
Expected: A number or literal "NaN", "Inf". (possibly signed, case insensitive
Is there a way to have the readall function skip these ,,, non-existing values in my data?
Code:
function [] = each_day_table(folder_referenced, output_folder_location)
dimention = size(folder_referenced) ;
for i = 1:dimention(2)
datastore_result = datastore(folder_referenced(i)) ;
original_data = readall(datastore_result) ;
new_table = new_table_useful_data(original_data) ;
[~, name, ext] = fileparts(folder_referenced(i)) ;
output_filename = fullfile(output_folder_location, "new_" + name + ext) ;
writetable(new_table, output_filename)
end
folder_with_files = dir(input_folder_location) ; % define directory where files are
filenames = fullfile({folder_with_files.folder}, {folder_with_files.name}) ; % access file path and name information
csvFiles = endsWith(filenames, ‘.csv’) ; % use logi → determining which values end in .csv (fullfile provides axtra info we don’t want)
filenames = filenames(csvFiles) ; % create cell array with all file names
each_day_table(filenames, output_folder_location) ; % applies all the functions to the files
I’ve attached a ference file. Hi y’all,
When I run my code I get an error:
Error using matlab.io.datastore.TabularDatastore/readall (line 196)
Unable to parse a "Numeric" field when reading row 39898, field 7.
Actual Text: "N,07121.27550,W,2,28,0.9,0.79,M,,,5,0131*01"
Expected: A number or literal "NaN", "Inf". (possibly signed, case insensitive
Is there a way to have the readall function skip these ,,, non-existing values in my data?
Code:
function [] = each_day_table(folder_referenced, output_folder_location)
dimention = size(folder_referenced) ;
for i = 1:dimention(2)
datastore_result = datastore(folder_referenced(i)) ;
original_data = readall(datastore_result) ;
new_table = new_table_useful_data(original_data) ;
[~, name, ext] = fileparts(folder_referenced(i)) ;
output_filename = fullfile(output_folder_location, "new_" + name + ext) ;
writetable(new_table, output_filename)
end
folder_with_files = dir(input_folder_location) ; % define directory where files are
filenames = fullfile({folder_with_files.folder}, {folder_with_files.name}) ; % access file path and name information
csvFiles = endsWith(filenames, ‘.csv’) ; % use logi → determining which values end in .csv (fullfile provides axtra info we don’t want)
filenames = filenames(csvFiles) ; % create cell array with all file names
each_day_table(filenames, output_folder_location) ; % applies all the functions to the files
I’ve attached a ference file. readall, missing data MATLAB Answers — New Questions