Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Import-Csv with powershell when headers have spaces.

Posted on 2013-01-10
3
Medium Priority
?
2,432 Views
Last Modified: 2013-01-28
I am using the following command to try and import a CSV file with powershell

import-csv file.csv | Where-Object {$_."File Name" like ".txt"}

This does not seem to work and I am sure there is an easy solution. All I want to do is read an excel file and return all rows where the filename field is like '.txt'.

Ideas?
0
Comment
Question by:Blowfelt82
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 19

Accepted Solution

by:
Raheman M. Abdul earned 2000 total points
ID: 38762323
import-csv file.csv | Where-Object {$_."File Name" like "*.txt"}
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 38762431
If you have difficulties to spot the difference (I had): The issue is that like needs wildcards. The space in your properties are no issue.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38762486
Try with..
import-csv file.csv | Where-Object {$_."File Name" -like "*.txt"}
or
import-csv file.csv | Where-Object {$_."File Name" -match ".txt$"}

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A brief introduction to what I consider to be the best editor for PowerShell.
A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Screencast - Getting to Know the Pipeline

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question