Hi team,
I encountered an issue while sending CSV data from command line to Edge Impulse.
Here is the script and the issue report below;
The issue report below;
Please can any member of the team assist me in resolving this issue.
Thank you
Hi team,
I encountered an issue while sending CSV data from command line to Edge Impulse.
Here is the script and the issue report below;
The issue report below;
Please can any member of the team assist me in resolving this issue.
Thank you
You need to post to the ingestion site:
https://ingestion.edgeimpulse.com/api/training/files
See the Python ingestion example in the man.
Thank you very much for your response.
Thank you so much for your support.
Please after replacing the url with the ingestion site, i got this error report,
I guess this should be about the format. If that is the case, how can I know the appropriate file format since I am converting streaming data to csv data file.
Thank you
Please post code as text in future so we can verify easier, and a sample of the CSV output.
The first line should be header information. Each sample should be on a newline.
I suspect you have got somehting incorrect on the dataframe.
Build the data first with headers, and use that to build the dataframe also ensure that the timestamps are in miliseconds:
Something like this:
data = {
'Timestamps': time_stamps,
'EEG Data': eeg_data
}
df = pd.Dataframe(data)
Your CSV should look something like this:
Timestamps,EEG Data
2023-09-12 14:00:00.000,1.23
2023-09-12 14:00:00.001,1.24
2023-09-12 14:00:00.002,1.25
2023-09-12 14:00:00.003,1.26
2023-09-12 14:00:00.004,1.27
See the importing CSV guide for more, and the associated git repo:
Hope this helps, please let us know how you get on and share any output / code as text.
Best
Eoin
Thank you very much for your prompt response.
I will send you the text script if i encounter any further issue.
Many thanks @Eoin
Here is the script below,
import pyxdf
import pandas as pd
import requests
API_KEY = ‘XXXXX’
PROJECT_ID = ‘278572’
EI_API_ENDPOINT = f’https://ingestion.edgeimpulse.com/api/training/files’
XDF_FILE_PATH = ‘C:/Users/apple/bci-essentials-python/sub-P36_mi_ses-MI_task-T1_run-001_eeg.xdf’
streams, header = pyxdf.load_xdf(XDF_FILE_PATH)
selected_stream = streams[0]
eeg_data = selected_stream[‘time_series’]
timestamps = selected_stream[‘time_stamps’]
timestamps_ms = [int(ts * 1000) for ts in timestamps]
data = {
‘Timestamps’: timestamps_ms,
‘EEG Data’: eeg_data
}
df = pd.DataFrame(data)
csv_file_path = ‘C:/Users/apple/bci-essentials-python.csv’
df.to_csv(csv_file_path, index=False)
with open(csv_file_path, ‘rb’) as file:
files = {‘file’: (csv_file_path, file, ‘application/octet-stream’)}
headers = {‘x-api-key’: API_KEY}
response = requests.post(EI_API_ENDPOINT, files=files, headers=headers)
if response.status_code == 200:
print(‘XDF data converted to CSV and uploaded to Edge Impulse successfully.’)
else:
print(f’Error uploading CSV data to Edge Impulse: {response.status_code} - {response.text}')
Did you have further issues? Its not clear from that.
Remember that the timestamp needs to be in mili seconds. Please make sure the CSV output is as expected: Importing CSV data
Best
Eoin