by Anonymous » 12 Apr 2025, 16:58
Ich versuche, Datenbank von OpenFoodFacts zu verwenden, aber ich begegne Parser -Fehler. Als ich versuchte, es zu lösen, begegne ich das
Problem mit dem Gedächtnis. />
https://fleuryc.github.io/oc_ingenieur- ... e/notebook />"
https://world.openfoodfacts.org/data/en ... oducts.csv"
Aufgenommen, mein Versuch
Code: Select all
import os.path
import pandas as pd
# define csv path
local_path = os.getcwd() + '\\'
csv_filename = 'fr.openfoodfacts.org.products.csv'
csv_path = local_path + csv_filename
# define the name of the file where I will record dataset corrected
corrected_file = 'OFF_corrected.csv'
corrected_file_path = local_path + corrected_file
# Apply correction and save it
with open(csv_path, 'r') as csv_file, open(corrected_file_path, 'a') as clean_file:
chunk_size=1000
for chunk in csv_file (chunksize=chunk_size):
clean_file.write(chunk.replace('\n\t', '\t'))
Mein Gehirn ist flüssig, danke für die Hilfe
Ich versuche, Datenbank von OpenFoodFacts zu verwenden, aber ich begegne Parser -Fehler. Als ich versuchte, es zu lösen, begegne ich das [url=viewtopic.php?t=20324]Problem[/url] mit dem Gedächtnis. />https://fleuryc.github.io/oc_ingenieur-ia_p3-preparez-donnees-pour-un-organisme-de-sante-publique/notebook />"https://world.openfoodfacts.org/data/en.openfoodfacts.org.products.csv"
Aufgenommen, mein Versuch
[code]import os.path
import pandas as pd
# define csv path
local_path = os.getcwd() + '\\'
csv_filename = 'fr.openfoodfacts.org.products.csv'
csv_path = local_path + csv_filename
# define the name of the file where I will record dataset corrected
corrected_file = 'OFF_corrected.csv'
corrected_file_path = local_path + corrected_file
# Apply correction and save it
with open(csv_path, 'r') as csv_file, open(corrected_file_path, 'a') as clean_file:
chunk_size=1000
for chunk in csv_file (chunksize=chunk_size):
clean_file.write(chunk.replace('\n\t', '\t'))
[/code]
Mein Gehirn ist flüssig, danke für die Hilfe