Hi all! I have the following problem. I have a list of different text lines that all has a comma in it. I want to keep the text to the left of the comma and delete everything that occurs after the comma for all the lines in the file.
Here is a sample line from the file:
1780375 "004956 , down , 943794 , 22634 , ET , 2115 ,
I'd like to delete the characters after the first comma:
I tried to make the program yet am having some trouble. Here is what i have so far:
datafile = open('C:\\middlelist3.txt', 'r')
smallerdataset = open('C:\\nocommas.txt', 'w')
counter = 1
for line in datafile:
print counter
counter +=1
datafile.rstrip(s[,])
smallerdataset.write(line)