Created
March 17, 2022 13:52
-
-
Save odinuv/cdaf83406a48c425cf6d44a35f301c59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "1465238", | |
"name": "Sample Transformation", | |
"description": "", | |
"created": "2022-03-16T18:01:59+0100", | |
"creatorToken": { | |
"id": 545, | |
"description": "ondrej.popelka@keboolaconnection.onmicrosoft.com" | |
}, | |
"version": 12, | |
"changeDescription": "Change Main", | |
"isDisabled": "false", | |
"isDeleted": "false", | |
"configuration": { | |
"parameters": { | |
"blocks": [ | |
{ | |
"name": "Block 1", | |
"codes": [ | |
{ | |
"name": "Main", | |
"script": [ | |
"from os import listdir\nfrom os.path import isfile, join\n\nprint('intables')\nmypath = '/data/in/tables'\nonlyfiles = [f for f in listdir(mypath)]\nprint(onlyfiles)\n\nprint('infiles')\nmypath = '/data/in/files'\nonlyfiles = [f for f in listdir(mypath)]\nprint(onlyfiles)\n\nprint('outtables')\nmypath = '/data/out/tables'\nonlyfiles = [f for f in listdir(mypath)]\nprint(onlyfiles)\n\nprint('outfiles')\nmypath = '/data/out/files'\nonlyfiles = [f for f in listdir(mypath)]\nprint(onlyfiles)\n\nimport csv\n\ncsvlt = '\\n'\ncsvdel = ','\ncsvquo = '\"'\nwith open('in/files/user.csv', mode='rt', encoding='utf-8') as in_file, open('out/tables/result.csv', mode='wt', encoding='utf-8') as out_file:\n writer = csv.DictWriter(out_file, fieldnames=['Name', 'Sales_Market'], lineterminator=csvlt, delimiter=csvdel, quotechar=csvquo)\n writer.writeheader()\n\n lazy_lines = (line.replace('\\0', '') for line in in_file)\n reader = csv.DictReader(lazy_lines, lineterminator=csvlt, delimiter=csvdel, quotechar=csvquo)\n for row in reader:\n # do something and write row\n writer.writerow({'Name': row['Name'] + 'ping', 'Sales_Market': row[\"Sales_Market\"]})\n" | |
] | |
} | |
] | |
} | |
] | |
}, | |
"storage": { | |
"input": { | |
"tables": [] | |
} | |
} | |
}, | |
"rowsSortOrder": [], | |
"rows": [], | |
"state": { | |
"component": [], | |
"storage": { | |
"input": { | |
"tables": [], | |
"files": [] | |
} | |
} | |
}, | |
"currentVersion": { | |
"created": "2022-03-17T14:34:03+0100", | |
"creatorToken": { | |
"id": 545, | |
"description": "ondrej.popelka@keboolaconnection.onmicrosoft.com" | |
}, | |
"changeDescription": "Change Main" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment