Export table data for use/analysis in Excel

Hi there,

I am pretty new to 3D-slicer but enjoying the features a lot.
I recently used the function “line profile” to collect data on a CBCT along a straight line. After plotting the curve in 2 dimension the individual values were found in a created table.
Since I wanted to use the values for further calculations (in excel) I was wondering which options of exporting are available.

Specifically asking, due to the conflict with excel by simply “copy and pasting” values. Hereby “,” and “.” are getting confused and values over 1.xx (in the table in 3D-slicer) are imported as higher values of 10000.xx. Values e.g. 0.9xx are saved the same but are not formated as numbers in excel.
Ignoring of predefined “,” and “.” in settings of excel does not solve the wrong importing of values over 1.xx into excel (still importing with 1000.x …).
See example below.

Is there any suggestion solving this issue?
Happy for any input.

Best

Example (distance - Hounfield Units):
a. Values in 3D-slicer:

|0.998547 - 195|
|1.0008 - 194|
|1.00304 - 193|

b. valsues in excel after importing

|0.998547 - 195.00
|10008.000000 - 194.00|
|100304.000000 - 193.00|

I would recommend to save the table and load the CSV file into Excel.

Hi there,

thanks for uyour input. Unfortunately this still houses the error of wring formating.

best

When you import the CSV file into Excel then your can choose . as decimal delimiter. This issue impacts all people who use Excel on systems with regional settings set to German (or other region that does not use decimal point). There are many solutions, for example see a handful of them here: CSV decimal dot in Excel - Stack Overflow

Alternatively, you can run this small code snippet in Python (for example, in Slicer’s Python console) to convert the tsv/csv file to xlsx:

csv_file = r"c:\tmp\Table.tsv"
xls_file = r"c:\tmp\Table.xlsx"

# Install pandas and openpyxl
try:
    import pandas as pd
    import openpyxl
except ImportError:
    pip_install("pandas openpyxl")
    import pandas as pd
    import openpyxl
# Read the TSV/CSV file and write it to an Excel file
df = pd.read_csv(csv_file, sep="\t", decimal=".")
df.to_excel(xls_file, index=False)