How to validate CSV file whether it is in correct format or not ?

Hi Everyone,

I want implement a validation on file upload field, whenever user uploads a CSV file system will validate and check whether the CSV file uploaded is in correct format or not ?

if file is not in correct format system will give the error "File is not in correct format"

  Discussion posts and replies are publicly visible

Parents
  • Typically when uploading an processing a CSV file (unless it is very small) we use an asynchronous pattern. The file is uploaded and the contents loaded to a staging table. The contents can then be validated and then, if valid, the data moved to the target operational table(s).

    In terms of implementing the actual validation, you can use JSON Schema Validation for the vast majority of the typical validations that you might want to apply.

    Use the JSON Tools plug-in the conduct JSON Schema validation (obviously you'll need convert your data in your staging table to JSON). If the volumes are very large you'll probably want to throttle the processing so as to not consume too much server resource in one go. If there are any Schema violations you'll need to write these somewhere. Whether the validation passes or fails you'll need to inform the original user since the processing is conducted asynchronously form the initial file upload.

    Visit JSON Schema Org for help with JSON Schemas

Reply
  • Typically when uploading an processing a CSV file (unless it is very small) we use an asynchronous pattern. The file is uploaded and the contents loaded to a staging table. The contents can then be validated and then, if valid, the data moved to the target operational table(s).

    In terms of implementing the actual validation, you can use JSON Schema Validation for the vast majority of the typical validations that you might want to apply.

    Use the JSON Tools plug-in the conduct JSON Schema validation (obviously you'll need convert your data in your staging table to JSON). If the volumes are very large you'll probably want to throttle the processing so as to not consume too much server resource in one go. If there are any Schema violations you'll need to write these somewhere. Whether the validation passes or fails you'll need to inform the original user since the processing is conducted asynchronously form the initial file upload.

    Visit JSON Schema Org for help with JSON Schemas

Children
No Data