Set the delimiter for PowerShell Import-Csv
How the -Delimiter and -UseCulture parameters of Import-Csv work for comma, tab, semicolon and space-separated files, with the limits of single-character delimiters and space-separated data.
Import-Csv reads delimited text and turns each row into an object whose property names come from the header row. It assumes commas by default. If your file uses tabs, semicolons, pipes or spaces, you need to tell it which character separates the fields. This review covers how to do that, what the setting changes, and when it does not fit your data.
Short answer
Use the -Delimiter parameter with a single character. For a tab, write the PowerShell escape sequence inside double quotes. For a space, pass a quoted space. If the file was produced by software that follows your system's regional list separator, -UseCulture can pick that character for you. -Delimiter and -UseCulture are alternatives and cannot be used together.
# Tab-separated
Import-Csv -Path .\data.tsv -Delimiter "`t"
# Semicolon-separated
Import-Csv -Path .\data.csv -Delimiter ';'
# Single-space-separated
Import-Csv -Path .\data.txt -Delimiter ' '
# Use the current culture's list separator
Import-Csv -Path .\data.csv -UseCulture
Is Import-Csv with a custom delimiter right for your data?
It fits when the file has one consistent single-character separator, a header row or a header you can supply with -Header, and quoting for any field that contains the separator. In that situation you get objects you can filter, sort and export by property name, without writing a parser.
The main tradeoff is that the parameter accepts exactly one character and treats every occurrence as a field boundary. Data that uses multi-character separators, runs of spaces for alignment, or unquoted separators inside values will not import correctly. That data needs preprocessing or a different approach.
Plain text is the better choice when you only need to view, search or forward the file unchanged. Get-Content or Select-String avoids converting the data to objects, so nothing about its layout can be reinterpreted.
What the delimiter setting actually changes
The setting changes how PowerShell parses the file. It does not change the file. The source bytes stay as they are, and the result exists only in memory as objects with string values. To produce a file with a different separator, you write one explicitly with Export-Csv or ConvertTo-Csv, which also accept -Delimiter.
# Convert a tab-separated file to a comma-separated one
Import-Csv -Path .\data.tsv -Delimiter "`t" |
Export-Csv -Path .\data.csv -NoTypeInformation
In Windows PowerShell 5.1, Export-Csv writes a #TYPE line at the top of the file unless you pass -NoTypeInformation. Newer PowerShell versions omit that line by default and still accept the switch, so including it is harmless in both.
Tab delimiters
PowerShell's escape character is the backtick, and escape sequences are expanded only inside double-quoted strings. So "t" is a tab character. In single quotes, 't' is two literal characters, a backtick and the letter t. That cannot be converted to a single delimiter character, so the command fails. The backslash form used in many other languages is not a PowerShell tab either. If quoting is awkward in your context, [char]9 is an equivalent way to write a tab.
Suppose a file contains these two lines, with tabs between the fields:
Name Dept Office
Ana Sales Room 4
With -Delimiter "`t", you get one object with the properties Name, Dept and Office and the values Ana, Sales and Room 4. The space in Room 4 is kept because only tabs split fields. Without the parameter, Import-Csv looks for commas and finds none. The result is a single property whose name is the entire header line, holding the entire data line as its value. If you see one long property name containing your column titles, the delimiter is wrong.
Space delimiters
A space works as a delimiter only when exactly one space separates each field. Every space counts, so two consecutive spaces produce an empty field between them. Runs of spaces are not collapsed. With the same sample data separated by spaces, Room 4 would split into two fields unless it is wrapped in double quotes:
Name Dept Office
Ana Sales "Room 4"
Column-aligned output padded with variable spaces is the common case where a space delimiter fails. One option is to normalize the spacing first and then parse the text with ConvertFrom-Csv, which takes the same -Delimiter parameter but works on strings instead of a file path. This only works if no field value itself contains spaces.
Get-Content .\aligned.txt |
ForEach-Object { ($_.Trim()) -replace ' +', ',' } |
ConvertFrom-Csv
Semicolons and -UseCulture
Some spreadsheet exports use a semicolon because the regional settings use the comma as the decimal mark. -UseCulture reads the list separator from the current culture, which you can inspect with (Get-Culture).TextInfo.ListSeparator. This is convenient when the file and the script run under the same regional settings. It becomes unreliable when the script runs on machines with different settings. In that case, name the character explicitly with -Delimiter.
Other things that affect the result
- Quoting: a field enclosed in double quotes can contain the delimiter, so a comma inside a quoted value does not split it.
- Headers: the first line becomes property names unless you pass -Header. If you pass -Header to a file that already has a header row, that row is imported as data.
- Data types: every value arrives as a string. Convert numbers or dates yourself before comparing or sorting them numerically.
- Encoding: the default encoding differs between Windows PowerShell 5.1 and later versions. Specify -Encoding when the file contains non-ASCII text, so characters are not misread.
- In-memory text: for data you already hold as a string, use ConvertFrom-Csv with the same -Delimiter value instead of Import-Csv.
Will the result stay usable after copying or sharing?
Tab-separated text is the most fragile when it is copied. Some editors, terminals and messaging tools turn tabs into spaces when you paste. After that, the tab delimiter matches nothing and the space delimiter hits the alignment problem described above. To check, look for tabs in the pasted text before importing it, for example with Select-String and a tab pattern. When you control the source, sharing the original file instead of pasted content avoids the problem.
Tabular data copied from a spreadsheet is commonly placed on the clipboard as tab-separated text. On systems where Get-Clipboard is available, piping it to ConvertFrom-Csv -Delimiter "`t" is a reasonable first attempt. Whether a particular application puts tabs on the clipboard was not tested here, so confirm with a small sample.
Formatted console output is for display only. Format-Table produces formatting instructions, not data, and its padded columns cannot be imported back reliably. To share data with another person or tool, export it with Export-Csv or ConvertTo-Csv and choose a delimiter the recipient expects. The comma is the most widely expected choice. Tabs are useful when values often contain commas.
Assistive technology and search are not directly affected, because the delimiter changes parsing, not how text is displayed. A file with an unexpected separator is still harder to read in a plain viewer, though, because the columns are not obvious. Naming files to match their content, such as .tsv for tab-separated data, helps both people and tools pick the right setting.
Evidence and gaps
This review describes documented parameter behavior and general PowerShell parsing rules. No version-specific test results, performance figures or application-specific clipboard checks were available for it. Before relying on a delimiter choice for a recurring job, import a few representative rows on the PowerShell version and regional settings where the script will run. Then confirm that the property names and the field count per row match what you expect.