JdV Active Member Licensed User Longtime User Mar 12, 2024 #1 Hello The CSV parser works brilliantly but as the library documentation (here) mentions not all CSV files are 100% formatted correctly. To illustrate this I have created the attached program. The 'good' CSV string has 3 columns in row 1 and 2. This processes OK. The 'bad' CSV string has 3 columns in row 1 but 4 rows in row 2. This causes the app to crash. It would be good if the CSV parser library had a function that could scan the input and return whether it's consistent or not, before attempting to process it. Regards Joe Attachments CSVTest.zip CSVTest.zip 10.2 KB · Views: 337 Last edited: Mar 12, 2024
Hello The CSV parser works brilliantly but as the library documentation (here) mentions not all CSV files are 100% formatted correctly. To illustrate this I have created the attached program. The 'good' CSV string has 3 columns in row 1 and 2. This processes OK. The 'bad' CSV string has 3 columns in row 1 but 4 rows in row 2. This causes the app to crash. It would be good if the CSV parser library had a function that could scan the input and return whether it's consistent or not, before attempting to process it. Regards Joe
Erel B4X founder Staff member Licensed User Longtime User Mar 12, 2024 #2 JdV said: The 'bad' CSV string has 3 columns in row 1 but 4 rows in row 2. This causes the app to crash. Click to expand... This is good. It means that you can wrap it with Try / Catch and catch this error. This is the standard way to handle errors.
JdV said: The 'bad' CSV string has 3 columns in row 1 but 4 rows in row 2. This causes the app to crash. Click to expand... This is good. It means that you can wrap it with Try / Catch and catch this error. This is the standard way to handle errors.