-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideoexporter.py
44 lines (33 loc) · 1.2 KB
/
videoexporter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import pandas as pd
import json
# Define the path to the Excel file
excel_file_path = 'C:/tmp/ashley.xlsx'
# Define the sheet name in the Excel file
sheet_name = 'Sheet1'
# Read data from the Excel file into a DataFrame
data = pd.read_excel(excel_file_path, sheet_name=sheet_name)
# Create an array to hold the entries
entries = []
# Loop through each row in the DataFrame
for index, row in data.iterrows():
# Create an entry dictionary and populate it with data from the row
entry = {
'description': row['description'],
'url': row['url'],
'host': row['host'],
'xlink': row['xlink'],
'xusername':row['xusername']
}
# Add the entry dictionary to the array
entries.append(entry)
# Define the path to save the JSON data as a text file
output_file_path = 'C:/tmp/ashley.json'
# Convert the array of entries to JSON
json_data = json.dumps(entries)
# Save the JSON data to the text file
try:
with open(output_file_path, 'w') as file:
file.write(json_data)
print("JSON data successfully saved to", output_file_path)
except Exception as e:
print("Error saving JSON data to file:", e)