![]() ![]() So, here I did got my answer but instead of printing it once, It is printing 7 times. Output userID,Is salary credited before 5th,Avg Salary of last 3 months,Avg Salary of last 6 months,Avg Balance before salary of last 3 months,Avg Balance before salary of last 6 monthsĦ79d3bad-155e-4b39-9ff7-7d564f408942,Yes,15453.33,15290.5,113.15,105.22 How should we convert to json if i get different patterns of csv log messages.Following is my json file input Ĭode with open('/Users/vrindabv/Documents/PycharmProjects/BankStatementEngine/test.json', "r") as f:į = csv.writer(open("/Users/vrindabv/Documents/PycharmProjects/BankStatementEngine/test.csv", "w"))į.writerow()į.writerow(, x, Call the ‘writer’ function passing the CSV file as a parameter and use the ‘writerow’ method to write the JSON file content (now converted into Python dictionary) into the CSV file. ![]() but my requirement is i need to convert csv (any pattern) to json.įor the above csv logs i converted like below json. You have to convert the JSON data into a Python dictionary using the ‘load’ method. So far i created script to convert one type of csv pattern(above showed) to json. I have a scenario, I am receiving logs in csv format to kinesis firehose directly and with help of lambda function (python) I need to transform the csv logs format to json format and return the output back to kinesis.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |