-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
  • 107,083
  • 22
  • 201
  • 376
Tom Pitts
  • 570
  • 7
  • 24

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.

Ivan
  • 885
  • 1
  • 9
  • 17