-3

My program is reading from a text file line by line. I want it to split each line's numbers into separate variables. For example:

This is the string it reads from the line in the text file:

FTSE,D,20160104,6242.32,6242.32,6071.01,6093.43,0

I would like each value before the comma placed into a variable:

A = 'FTSE'

B = 'D'

C = '20160104'

...

Pseudo code:

for line in file:
     line.split(',') 
     A = firstsplit 
     B = secondsplit
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Tom Pitts
  • 590
  • 7
  • 25

1 Answers1

1
for line in file:
     A,B,C,D,E,F,G,H = line.split(',') 

This only works if you are sure that the line will only contain 8 parts.

Zixian Cai
  • 945
  • 1
  • 10
  • 17