I am new to programming and I am trying to scan in strings from a text file and assign each string to variables but some lines in the text file have 4 variables I need to assign but others only have 3. On the lines that only have 3 variables I need to assign what would be the 4th variable a value without assigning it the first string in the next line. I managed to get to the point where it assigns all the variables correctly except for the would be 4th variables on the lines with only 3 variables for me to assign. on these variables it assigns them a blank space but no matter what i try I cannot compare these blank spaces in an if statement to assign them the correct strings. This is the code I have. This is the text file I am scanning. I have checked value stored in these variables and they are not null it shows a blank space but whenever I try " " or any escape characters it does not work.
Asked
Active
Viewed 403 times
1
-
It would be helpful if you post your code as well. – iamimran Dec 01 '19 at 12:01
-
There is a link a picture of the code. Should I have included more? – Jonathan Dec 01 '19 at 21:07
-
What you can do is read the file line by line and then split the line with your delimiter (in this case is ","). After split you will receive an array of items. Check if it has three or four items and work accordingly. Hope this helps. – iamimran Dec 02 '19 at 14:19