You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
string_file_content+=f"Content from file uploaded named `{file_name}` (also saved as `{csv_file_name}`):\n```csv\n{csv}```\n"
1245
+
string_file_content+=f"Content from uploaded Excel file `{file_name}` (converted and saved as `{csv_file_name}` - use this CSV file for all Read File and pandas operations):\n```csv\n{csv}```\n"
1232
1246
return (
1233
-
f"Converted [{file_name}]({file_path}) and converted to CSV format at [{csv_file_name}]({csv_file_path}).",
1247
+
f"Converted [{file_name}]({file_path}) to CSV format at [{csv_file_name}]({csv_file_path}). Use `{csv_file_name}` for file operations.",
csv_notice=f"**Note**: Excel file `{filename}` has {len(xl.sheet_names)} sheets. Converted to: {', '.join(csv_files)}. Reading first sheet (`{csv_files[0]}`).\n\n"
481
+
csv_filepath=self.safe_join(csv_files[0])
482
+
csv_filename=csv_files[0]
483
+
else:
484
+
# Single sheet
485
+
df=pd.read_excel(filepath)
486
+
df.to_csv(csv_filepath, index=False)
487
+
csv_notice=f"**Note**: Excel file `{filename}` converted to `{csv_filename}` for reading.\n\n"
488
+
exceptExceptionase:
489
+
returnf"Error: Failed to convert Excel file to CSV: {str(e)}"
490
+
else:
491
+
csv_notice=f"**Note**: Reading CSV version `{csv_filename}` of Excel file `{filename}`.\n\n"
492
+
493
+
# Update filepath to read the CSV version
494
+
filepath=csv_filepath
495
+
filename=csv_filename
496
+
455
497
# Read the file lines
456
498
withopen(filepath, "r", encoding="utf-8") asf:
457
499
lines=f.readlines()
@@ -479,7 +521,8 @@ async def read_file(
479
521
lines_returned=len(selected_lines)
480
522
481
523
# Build header with line information
482
-
header= (
524
+
header=csv_notice# Include Excel->CSV conversion notice if applicable
525
+
header+= (
483
526
f"Lines {actual_start}-{actual_end} of {total_lines} total lines:\n"
0 commit comments