Is there any way or script to parse CSV logs (any pattern) to Json format using lambda function (python) in kinesis. I haven't tested this code as I don't have your csv-files but it gives a direction to dig. I have a scenario, I am receiving all logs in csv format to kinesis firehose directly and with help of lambda function (python) I need to transform the csv logs to json and return the output back to kinesis. You'll see hands-on examples of working with Python's built-in 'json' module all the way up to encoding and decoding custom objects. Path_2 = r"C:\Users\LordK\Desktop\Daten Krmnicek\Versuch JSON STruktur\MünzenID.csv"ĭf1 = pd.read_csv(path_1, names=FuFelder)ĭf2 = pd.read_csv(path_2, names=MüFelder) In this tutorial you'll learn how to read and write JSON-encoded data using Python. Path_json = r"C:\Users\LordK\Desktop\Daten Krmnicek\Versuch JSON STruktur\Skript\out.json" Path_1 = r"C:\Users\LordK\Desktop\Daten Krmnicek\Versuch JSON STruktur\FundorteID.csv" Your task could be accomplished in pandas much faster as it has built-in join function: import pandas as pd Move output.append(Fundrow)įor the future working with csv files I recommend using pandas library. foutopen ('1300 restaurant data.csv', 'a', encoding'utf8') now the rest: for num in range (1,13): f open (str (num) '.csv',encoding'utf8') for line in f: fout.write (line) f.close () not really needed fout. You are updating output before you find necessary itemrow from MünzenReader. 2 Answers Sorted by: 0 This is my code snippet for merging 13 excel file in to 1 file. Right now i get the findplaces FuFelder displayed, but the nested list Fundrow ist still empty. Json.dump(output, jsonfile,sort_keys=True) MünzenReader = csv.DictReader( Münzen, fieldnames=MüFelder) MüFelder = įundorteReader = csv.DictReader( Fundorte, fieldnames=FuFelder) Münzen = open(r"C:\Users\LordK\Desktop\Daten Krmnicek\Versuch JSON STruktur\MünzenID.csv", 'r')įuFelder = Jsonfile = open(r"C:\Users\LordK\Desktop\Daten Krmnicek\Versuch JSON STruktur\Skript\out.json", 'w') The code used below: Fundorte = open(r"C:\Users\LordK\Desktop\Daten Krmnicek\Versuch JSON STruktur\FundorteID.csv", 'r') I want to create a JSON, so that i can implement geodata in the next step and create a nested GeoJason from this dataset.Īfterwards i wanted to use the Geodata in Leaflet. I wanted to create a nested structure, where every coind of a Findplace is linked inside a nested part of my findplace (Fundorte). I have two tables one containing Information over a findplace of archeological finds with a ID then i have a second table with many coins (80.000) linked with the ID to the findplaces. Problems joining two CSV Tables over ID and exporting as a nested JSON
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |