Soldato
I have a text file looking like this:
I want to read this back in and take the path value, and the year value and do something with them (copy image into a dir named YEAR)
When I try to access the data I'm getting a character reference rather than the item e.g.
gives out put of
I.e. the 1 and 7 character
but I want
what am i doing wrong?
Code:
(0, 'M:\\IMAGES\\BSCANS\\1\\BOX007\\20066\\003984.jpg', '003984.jpg', 1879, 2580, 1.0, 'FF', '2001')
(1, 'M:\\IMAGES\\BSCANS\\1\\BOX007\\20066\\003985.jpg', '003985.jpg', 3569, 2584, 2.0, 'BI', '2001')
(2, 'M:\\IMAGES\\BSCANS\\1\\BOX007\\20066\\003986.jpg', '003986.jpg', 3573, 2584, 2.0, 'BI', '2001')
(3, 'M:\\IMAGES\\BSCANS\\1\\BOX007\\20066\\003987.jpg', '003987.jpg', 3573, 2584, 2.0, 'BI', '2001')
(4, 'M:\\IMAGES\\BSCANS\\1\\BOX007\\20066\\003988.jpg', '003988.jpg', 3569, 2589, 2.0, 'BI', '2001')
(5, 'M:\\IMAGES\\BSCANS\\1\\BOX007\\20066\\003989.jpg', '003989.jpg', 3578, 2575, 2.0, 'BI', '2001')
(6, 'M:\\IMAGES\\BSCANS\\1\\BOX007\\20066\\003990.jpg', '003990.jpg', 3546, 2566, 2.0, 'BI', '2001')
I want to read this back in and take the path value, and the year value and do something with them (copy image into a dir named YEAR)
When I try to access the data I'm getting a character reference rather than the item e.g.
Code:
print "\nReading the entire file into a list."
text_file = open("M:\\IMAGES\\FILES\\0_FILEDATA\\1_BOX007_20067.log", "r")
lines = text_file.readlines()
#print lines
print len(lines)
for line in lines:
print "FILE", line[1], "YEAR", line[7]
text_file.close()
gives out put of
Code:
FILE 0 YEAR \
FILE 1 YEAR \
FILE 2 YEAR \
FILE 3 YEAR \
FILE 4 YEAR \
FILE 5 YEAR \
FILE 6 YEAR \
I.e. the 1 and 7 character
but I want
Code:
FILE M:\\IMAGES\\BSCANS\\1\\BOX007\\20066\\003984.jpg YEAR 2001
FILE M:\\IMAGES\\BSCANS\\1\\BOX007\\20066\\003985.jpg YEAR 2001
FILE M:\\IMAGES\\BSCANS\\1\\BOX007\\20066\\003986.jpg YEAR 2001
FILE M:\\IMAGES\\BSCANS\\1\\BOX007\\20066\\003987.jpg YEAR 2001
FILE M:\\IMAGES\\BSCANS\\1\\BOX007\\20066\\003988.jpg YEAR 2001
FILE M:\\IMAGES\\BSCANS\\1\\BOX007\\20066\\003989.jpg YEAR 2001
FILE M:\\IMAGES\\BSCANS\\1\\BOX007\\20066\\003990.jpg YEAR 2001
what am i doing wrong?
Last edited: