This file contains hidden or 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
| # Ugly Code | |
| add_address(road, block, city, state, country) | |
| # Clean Code | |
| add_address(address: Address) |
This file contains hidden or 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
| # Ugly code | |
| def call(arr): | |
| arr.append(1) | |
| call(arr) | |
| # Clean Code | |
| def call(arr): | |
| arr.append(1) | |
| return arr |
This file contains hidden or 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
| cnt += batch_size | |
| if cnt >= total_row: | |
| pds = get_all(files, chunksize=batch_size) | |
| cnt = 0 |
This file contains hidden or 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
| def data_generator(): | |
| total_row = NUMBER_OF_ROWS | |
| files = [ | |
| 'a.csv', | |
| 'b.csv', | |
| 'c.csv', | |
| 'd.csv', | |
| ] | |
| pds = get_all(files, chunksize=batch_size) |
This file contains hidden or 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
| def merge_all(*args): | |
| tmp = None | |
| args = args[0] | |
| for arg in args: | |
| if tmp is None: | |
| tmp = arg | |
| else: | |
| tmp = pd.merge(tmp, arg, how='inner', on=['id']) | |
| return tmp |
This file contains hidden or 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
| def get_all(*args, chunksize): | |
| pds = [] | |
| args = args[0] | |
| for arg in args: | |
| pds.append(pd.read_csv(f'{BASE_PATH}/{arg}', chunksize=chunksize)) | |
| return pds |
This file contains hidden or 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
| def get_all(*args, chunksize): | |
| pds = [] | |
| args = args[0] | |
| for arg in args: | |
| pds.append(pd.read_csv(f'{BASE_PATH}/{arg}', chunksize=chunksize)) | |
| return pds | |
| def merge_all(*args): | |
| merged = None | |
| args = args[0] |
This file contains hidden or 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
| import csv | |
| def data_generator(): | |
| with open('nlp.csv') as fp: | |
| reader = csv.reader(fp) | |
| for row in reader: | |
| yield row | |
| for row in data_generator(): | |
| print(row) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
| from flask import Flask | |
| app = Flask(__name__) | |
| @app.route('/', methods=['GET']) | |
| def hello_world(): | |
| return 'Hello World!' | |
| if __name__ == '__main__': | |
| app.run(debug=True) |