Hello,
I checked github examples and documentations but I did not get the best solution to read .txt and convert the dataframe. I can do it when I read the data from the path (from my personal work that I prepared on PyCharm) But, when I tried to upload the data;
page_2.data_type.file = FileField(‘Upload a file’, file_types=[‘.txt’], max_size=5_000_000)
I cannot read it with my current code block:
…
elif params.page_2.data_type.record == “Multicolumn Acceleration”:
with open(params.page_2.data_type.file, "r") as file:
lines = file.readlines()
# Skip the first line of the file
lines = lines[params.page_2.data_conf.skipped_line:]
# Split each row into individual values
data = []
for line in lines:
values = line.split()
for i in range(0, len(values), params.page_2.data_conf.num_col):
row = [float(v) for v in values[i:i + params.page_2.data_conf.num_col]]
data.append(row)
df = pd.DataFrame(data)
As I understood I cannot use open() function if I try to read upload file without the path. Is this possible to read .txt file with any way? I also checked @ParamsFile but I got and error like “you cannot use this entity etc.”
What is the best solution for that?
Thanks for the help for now.