Spaces:
Sleeping
Sleeping
Download analytics_v01.py from kaurdotai/scripti: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/kaurdotai/scripti/resolve/main/analytics_v01.py
- Command line
-
hf download hf://spaces/kaurdotai/scripti/analytics_v01.py
-
curl -L -o analytics_v01.py https://huggingface.co/spaces/kaurdotai/scripti/resolve/main/analytics_v01.py
1.06 kB
| import pandas as pd | |
| import pprint | |
| import ast | |
| import json | |
| import argparse | |
| # ... existing imports ... | |
| # Specify the path to your CSV file | |
| file_path = 'data/logged_data_hub_v01.csv' | |
| def process_data(idx): | |
| # Read the CSV file into a DataFrame | |
| df = pd.read_csv(file_path) | |
| # Display the DataFrame | |
| json_story = (df.iloc[idx, 1]) # iloc[:, 1] selects all rows of the second column | |
| str_feedback = (df.iloc[idx, 2]) | |
| # Convert the string to a Python object | |
| data_list = ast.literal_eval(json_story) | |
| filtered_data = [{"role": item["role"], "content": item["content"]} for item in data_list] | |
| # Print the data in pretty JSON format | |
| print(json.dumps(filtered_data, indent=4)) | |
| print(str_feedback) | |
| if __name__ == "__main__": | |
| # Set up command line argument parsing | |
| parser = argparse.ArgumentParser(description='Process data from CSV file.') | |
| parser.add_argument('idx', type=int, help='Index of the row to process') | |
| args = parser.parse_args() | |
| # Call the function with the provided index | |
| process_data(args.idx) |