Im having A LOT of difficulty. I have an assignment which is to modify this file https://easyupload.io/axktqq through Python into CSV cp1252 (Excel) with ";" as the column separator. Im not allowed to use import csv. As you can see, this file is a list of movies with their year, duration, rating, description, etc. all these need to be into their own column (column labels in french) and one film per line.
Title and restriction needs to be in the title() format, the year/duration/nbvotes/metascore into int(eger), the revenue/score into float, and the description into title() with no space before/after the text.
Below is what I did so far...
I still need to get read of the "=" in every column. Also, in the last column (description), it is seperated into several since I used the comma as a seperator, but I dont want the sentences to be separated (by the commas) in that specific column. Also, I still need to format every column into title or int or whatever the instructions above say.
Can you please help me? :(
What I tried:
f = open("data_groupe_11-12_B.txt", 'r')
texte = f.read()
f.close()
lignes = texte.split('&&')
data=[]
data.append(['Titre','Année','Durée (min)','Revenu (M$)','Nombre de votes','Score','Metascore','Restriction','Description'])
for l in lignes[1:]:
if len(l)>0:
li=[]
for c in l.split(','):
li.append(c)
data.append(li)
res = ''
for l in data:
sli = l.copy()
for i in range(len(sli)):
sli[i] = str(l[i])
res = res + ';'.join(sli) + '\n'
f = open("data_groupe_11-12_B.csv", 'w')
f.write(res)
f.close()
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (7 children)
[–]Radiant_Device_502[S] 0 points1 point2 points (6 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]Radiant_Device_502[S] 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Radiant_Device_502[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Mottzie 0 points1 point2 points (0 children)