Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6942097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:58:17+00:00 2026-05-27T12:58:17+00:00

How does one access data imported from a CSV file by using dynamic note

  • 0

How does one access data imported from a CSV file by using dynamic note property names? That is, one doesn’t know the colunm names beforehand. They do match a pattern and are extracted from the CSV file when the script runs.

As for an example, consider a CSV file:

"Header 1","Header A","Header 3","Header B"
0,0,0,0
1,2,3,4
5,6,7,8

I’d like to extract only columns that end with a letter. To do this, I read the header row and extract names with a regex like so,

$reader = new-object IO.StreamReader("C:\tmp\data.csv")
$line = $reader.ReadLine()
$headers = @()

$line.Split(",") | % {
    $m = [regex]::match($_, '("Header [A-Z]")')
    if($m.Success) { $headers += $m.value } }

This will get all the column names I care about:

"Header A"
"Header B"

Now, to access a CSV file I import it like so,

$csvData = import-csv "C:\tmp\data.csv"

Import-CSV will create a custom object that has properties as per the header row. One can access the fields by NoteProperty names like so,

$csvData | % { $_."Header A" } # Works fine

This obviously requires one to know the column name in advance. I’d like to use colunn names I extracted and stored into the $headers. How would I do that?

Some things I’ve tried so far

$csvData | % { $_.$headers[0] } # Error: Cannot index into a null array.
$csvData | % { $np = $headers[0]; $_.$np } # Doesn't print anything.
$csvData | % { $_.$($headers[0]) } # Doesn't print anything.

I could change the script like so it will write another a script that does know the column names. Is that my only solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:58:17+00:00Added an answer on May 27, 2026 at 12:58 pm

    the first thing ( and the only one… sorry) that came in my mind is:

    $csvData | % { $_.$(( $csvData | gm | ? { $_.membertype -eq "noteproperty"} )[0].name) }
    

    for get the first’s column values and

    $csvData | % { $_.$(( $csvData | gm | ? { $_.membertype -eq "noteproperty"} )[1].name) }
    

    for second column and so on….

    is this what you need?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Where does one access the data from a parsed xml file when using libxml?
This is a continuation of the post How does one access a method from
Using Python, how does one parse/access files with Linux-specific features, like ~/.mozilla/firefox/*.default ? I've
I want to abstract data access from my model. I have classes that have
How does one add a comment to an MS Access Query, to provide a
How does one go about authoring a Regular Expression that matches against all strings
How does one convert an image from one color profile to another (screen to
How does one invoke a groovy method that prints to stdout, appending the output
I'm looking for a common data access framework that will provide portability across various
I have a Access Data Project that connects to an SQL server database. Recently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.