सामग्री पर जाएँ

लेसन 4 · Reading and Writing Data

Reading CSV and Excel Files in KNIME

Read CSV, Excel, and other files into KNIME, check delimiters, headers, and encodings, and use the Transformation tab to rename, filter, and retype columns.

Most workflows begin with a file. If the data is read incorrectly, every later step is wrong, often without any error message. This lesson shows how to choose a reader node and how to check what it produced.

Which reader?

KNIME has a reader for each common format. The ones you will use most are:

Node Use it for
CSV Reader Comma or other delimiter separated text files
Excel Reader Spreadsheet workbooks
File Reader General text files
Table Reader KNIME's own table format, which keeps column types

You can also drag a file from your computer onto the canvas, and KNIME creates a suitable reader.

Reading a CSV file

Imagine a file named orders.csv:

TEXT
order_id;order_date;customer;amount
1001;2026-11-02;Mara Lind;49,90
1002;2026-11-03;Ken Ito;120,00
1003;2026-11-03;Sara Haddad;15,50

Notice two regional habits: fields are separated by semicolons, and the decimal mark is a comma. A reader configured for commas would squeeze everything into one column. In the CSV Reader dialog, look for settings for:

  • the column delimiter (here a semicolon),
  • whether the first row is a header,
  • the decimal separator, if available, or type conversion afterward,
  • the file encoding, such as UTF-8, so that names with accents appear correctly.

The reader can detect many of these settings automatically. Treat auto-detection as a first guess and read the preview.

Python Stand-in: reading the semicolon file with csv

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Reading Excel files

The Excel Reader lets you choose the sheet and, optionally, a cell range. Spreadsheets are made for people, so they often break the assumptions a reader needs. Watch for:

  • Title rows above the real header.
  • Blank rows or columns used for layout.
  • Merged cells, which leave gaps.
  • Totals at the bottom that would be counted again in your sum.
  • Dates or numbers typed as text in some cells.

Skip extra rows in the dialog or filter them afterward. If you control the source, ask for a plain data sheet with one header row and no totals.

The Transformation tab

Table-based readers such as CSV Reader and Excel Reader include a Transformation tab. There you can reorder, filter, rename, and change the type of columns before data enters your workflow. The reader analyzes the file while you configure it, which lets later nodes know the column names before you execute.

Transformation tab

Reorder Change column order
Filter Drop columns early
Rename Use clear names
Retype Fix data types
1 / 2

The analysis looks at a limited number of rows. If a column holds only numbers at the top and text far below, the guessed type can be wrong. The limit can be changed in the advanced settings, and there are options that decide how to treat files whose structure changes between runs. Read those options carefully when a workflow processes new files regularly.

Keep identifiers as text

Product codes, postal codes, and account numbers look like numbers but are labels. If read as numbers, leading zeros disappear and long codes may lose precision. Set them to text.

Python Stand-in: leading zeros lost by a number type

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A checklist after reading

After the reader runs, open its output and confirm:

  1. The row count matches the file (excluding header and totals).
  2. Column names are correct and unique.
  3. Dates and numbers have date and number types.
  4. Accented characters look correct.
  5. No column is full of missing values unexpectedly.

Do not trust a reader just because it turned green. A wrong delimiter, a skipped row, or text amounts all execute without errors. Compare the row count and a column total with the source file.

Encoding and regional formats

A text file is a sequence of bytes, and the encoding says which character each byte sequence means. If a file was saved in one encoding and read as another, accented letters turn into strange symbols. Names such as Müller or José are good test values. If they look wrong, change the encoding setting and check again. UTF-8 is the most common choice today, but older systems may export something else, so ask the owner of the file.

Regional settings cause quieter problems:

  • A thousands separator such as 1.200 can mean one thousand two hundred in one country and one point two in another.
  • Dates may be day first or month first.
  • Yes and no values may be written in local words.

When in doubt, read the column as text and convert it in a later node where the rule is visible. This keeps the original characters available while you check.

Handling imperfect files

Real files have short rows, extra delimiters inside text, or a stray note at the bottom. Quoted fields allow a delimiter inside a value, such as "Smith, Jane". If the quote character setting is wrong, one value splits into two and every column after it shifts. When rows look shifted, open the raw file in a plain text editor and find the first bad line.

Some readers offer options for rows that are shorter than the header or that fail type conversion. Be cautious with options that silently skip problems. A skipped row is a lost row, so count what you read and compare it with the source. If the source system can report its own record count or total, use that as your reference.

Practice task

Create a small CSV file in a text editor with four rows. Include one name with an accent, one value containing a comma inside quotes, one postal code that begins with zero, and one empty amount. Read it with CSV Reader and verify all four features survive. Then change the delimiter setting on purpose and describe what happens. Seeing a failure on a file you understand makes the same failure easy to recognize later.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. A semicolon-separated file arrives as one column. What is most likely wrong?

    If the delimiter does not match the file, KNIME cannot split the fields.
  2. 2. What can you do in the Transformation tab of a table-based reader?

    The tab shapes columns as they are read.
  3. 3. Why should a postal code usually be read as text?

    Codes are labels; converting them to numbers can change them.

Summary

  • Use CSV Reader, Excel Reader, File Reader, or Table Reader as the format requires.
  • Check delimiter, header, decimal mark, and encoding rather than trusting auto-detection.
  • Clean up spreadsheet layout, such as title rows and totals.
  • Use the Transformation tab to shape columns early.
  • Verify row counts and types right after reading.

Next: File Paths and Reading Multiple Files

आपकी प्रगति इसी ब्राउज़र में सेव होती है। खाते की ज़रूरत नहीं है।