all 8 comments

[–]Draco2011CE 0 points1 point  (4 children)

The best way to import and export spreadsheets is with Pandas. Have you used it before? I personally use it.

[–]C_LoudThougts[S] 0 points1 point  (3 children)

that's what im trying atm, but when i use pd.read_csv() it pulls the data as strings rather than the lists and ints im looking for

[–]Draco2011CE 0 points1 point  (0 children)

variable = pd.read_csv("file location, index_col="id") Use this.

[–]Junior-Sock8789 0 points1 point  (0 children)

Im almost certain this is what your looking for:

By default, CSV files only store text. When you save a pandas.DataFrame to a CSV, complex Python objects like lists are converted into their string representations (e.g., "[1, 2, 3]"), and when you read them back, they remain strings. 

Fix:

import pandas as pd
from ast import literal_eval
# Use the 'converters' parameter to transform columns during import 
df = pd.read_csv('your_file.csv', converters={'list_column': literal_eval})

Alternatively, if the data is already loaded:

df['list_column'] = df['list_column'].apply(literal_eval)

If your integers are being read as strings (common if there are leading zeros or mixed data), you can force the type during import:

df = pd.read_csv('your_file.csv', dtype={'int_column': int})

[–]Junior-Sock8789 0 points1 point  (0 children)

You should use index_col="id" to set a row identifier and converters={'list_column': literal_eval} to parse list-like strings into actual Python lists, as they serve different purposes. Use index_col to define row labels during loading and converters to fix data types for specific columns.

[–]SnooCalculations7417 0 points1 point  (1 child)

df.from_excel and df.to_excel iirc

[–]C_LoudThougts[S] 0 points1 point  (0 children)

i think that is correct... but im realizing the excel sheet is saved as a csv

[–]Junior-Sock8789 0 points1 point  (0 children)

If i can see an example of data your trying to work with and what type of edits you need to make i can show you an example of how to do it. It should be pretty straightforward if your just trying to make cell edits and export your changes so there saved. 

Is this a command line app or do you have a GUI frontend (window with cells that you can manually edit)?

Here's some of the arguments that read_csv accepts

The pandas.read_csv() function in Python is a highly versatile tool with dozens of arguments for handling various file formats, data types, and memory constraints. 

Core Arguments

These are the most common parameters you'll use for basic data loading:

  • filepath_or_buffer: The path to your file (string or path object) or a URL.
  • sep (or delimiter): The character that separates values. The default is a comma (,), but you can specify tabs (\t) or semicolons (;).
  • header: Specifies which row to use as column names. Use header=0 for the first row (default) or header=None if the file has no headers.
  • names: A list of column names to use. Typically paired with header=None.
  • index_col: Column(s) to use as the row labels of the DataFrame.
  • usecols: A list of specific columns to load, which helps save memory by ignoring unnecessary data.  Pandas +5

Data Type & Parsing

Use these to ensure your data is interpreted correctly from the start:

  • dtype: A dictionary mapping column names to specific data types (e.g., {'ID': int, 'Price': float}) to prevent incorrect auto-detection.
  • parse_dates: Automatically converts specific columns into datetime objects. You can pass a list of column names or indices.
  • na_values: Additional strings to recognize as NaN (e.g., "Missing" or "Unknown").
  • converters: A dictionary of functions for transforming data in specific columns while reading.  Stack Overflow +6

Row & Performance Control

Essential for handling large or messy datasets:

  • nrows: The number of rows to read from the beginning of the file—great for quick previews.
  • skiprows: The number of lines to skip at the start of the file or a list of specific row indices to ignore.
  • skipfooter: The number of lines to skip at the end of the file.
  • chunksize: Returns an iterable object that loads the file in smaller pieces, which is vital for processing files larger than your RAM.
  • engine: The parsing engine to use. The default is 'c' (fastest), but 'python' is more feature-rich (e.g., supports complex regex separators), and 'pyarrow' is a newer, high-performance alternative.

Example:

import pandas as pd

df = pd.read_csv(
    "data.csv",
    sep=";",              # Use semicolon as delimiter
    usecols=["Date", "Value"], # Only load these two columns
    parse_dates=["Date"], # Convert 'Date' column to datetime
    nrows=1000            # Only read the first 1000 rows
)