Skip to main content
Lewis_King
Gold ⭐️
Jul 13, 2022 12:25 AM UTC
Solved

Index for header 'filename' is 1 but CSVRecord only has 1 values error

Hello. I am simply spliting a csv file into two based on their row values. and when I run it through the QueryRecord processor, I get the error below. What could be the possible fix for this? Sample csv is as follows 

 

GradeNm   ,CattleBreedNm   ,CattleGenderNm   ,Price
C++            ,beef_cattle          ,Female                  ,10094
C++            ,hanwoo               ,Female                  ,12001
C++            ,beef_cattle          ,Male                       ,12704
B++            ,milk_cow             ,Female                   ,16942
 
The error 
화면 캡처 2022-07-13 091701.png
araujo
araujoAnswer
Platinum ⭐️⭐️⭐️
Jul 13, 2022 2:13 AM UTC

@Lewis_King ,

 

This error means that some line(s) in your flowfile have less than 4 fields. Empty lines are typically ignored but if you have a trailing line, for example, with a space in it, that space will be interpreted as the first field (GradeNm) and the other fields will be missing, which could lead to this sort of problem.

 

Check your input file for trailing lines or lines with less than 3 commas in it.

 

If the problem is being caused by a blank line with spaces, for example, you could use the ReplaceText processor to remove those spaces, as shown below:

 

araujo_0-1657678374647.png

 

 

Cheers,

André

-- Was your question answered? Please take some time to click on "Accept as Solution" below this post. If you find a reply useful, say thanks by clicking on the thumbs up button.

2 replies

araujo
Platinum ⭐️⭐️⭐️
araujoAnswer
Platinum ⭐️⭐️⭐️
Jul 13, 2022 2:13 AM UTC

@Lewis_King ,

 

This error means that some line(s) in your flowfile have less than 4 fields. Empty lines are typically ignored but if you have a trailing line, for example, with a space in it, that space will be interpreted as the first field (GradeNm) and the other fields will be missing, which could lead to this sort of problem.

 

Check your input file for trailing lines or lines with less than 3 commas in it.

 

If the problem is being caused by a blank line with spaces, for example, you could use the ReplaceText processor to remove those spaces, as shown below:

 

araujo_0-1657678374647.png

 

 

Cheers,

André

Translate
-- Was your question answered? Please take some time to click on "Accept as Solution" below this post. If you find a reply useful, say thanks by clicking on the thumbs up button.
Lewis_King
Gold ⭐️
Jul 13, 2022 2:28 AM UTC

Thank you so much for the help! this solved my problem

Translate