Download data/data_converter.py from ManojAlexender/Git_commit_classification: direct link, hf CLI and curl.
- Browser
- Download file 722 Bytes
-
https://huggingface.co/ManojAlexender/Git_commit_classification/resolve/main/data/data_converter.py
- Command line
-
hf download hf://ManojAlexender/Git_commit_classification/data/data_converter.py
-
curl -L -o data_converter.py https://huggingface.co/ManojAlexender/Git_commit_classification/resolve/main/data/data_converter.py
722 Bytes
| import json | |
| # Input and output file paths | |
| input_filepath = 'commit_data_hpc.jsonl' | |
| output_filepath = 'commit_data_hpc_modified.jsonl' | |
| with open(input_filepath, 'r') as infile, open(output_filepath, 'w') as outfile: | |
| idx = 1 # Starting index | |
| for line in infile: | |
| # Parse the line as JSON | |
| data = json.loads(line.strip()) | |
| # Rename 'commit_message' key to 'func' | |
| data['func'] = data.pop('commit_message') | |
| # Add 'idx' key | |
| data['idx'] = idx | |
| # Serialize back to JSON and write to the output file | |
| outfile.write(json.dumps(data) + '\n') | |
| # Increment the index | |
| idx += 1 | |
| print("File modification complete!") | |