Quantcast
Channel: Active questions tagged header - Stack Overflow
Viewing all articles
Browse latest Browse all 653

The member "0" is already present

$
0
0

I have a powershell code that reads in a file and for every record it processes it executes a "piconfig" utility command with the record as part of that commmand. However it stops running after the first record with a "The member "0" is already present. I thought this error only appears if a column repeats itself. The in put file itself does not have any column headers, and the attributes (e.g. name, description, location1..etc..etc) in the command line don't appear to repeat either.

The Error

Import-Csv : The member "0" is already present.At D:\OpNetTags\scripts\PiconfigProcUtililty1.0.ps1:8 char:12+ $records = Import-Csv -Path $inputFile+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : NotSpecified: (:) [Import-Csv], ExtendedTypeSystemException+ FullyQualifiedErrorId : AlreadyPresentPSMemberInfoInternalCollectionAdd,Microsoft.PowerShell.Commands.ImportCsvCommand

The Code

# Define the input and log file paths$inputFile = "D:\OpNetTags\tags\00_UFL_TEST_PROC.csv"$logFile = "D:\OpNetTags\logs"# Read the CSV file$records = Import-Csv -Path $inputFile# Process each recordforeach ($record in $records) {    # Construct the PIConfig command    $piconfigCommand = @"@table pipoint, classic@mode create, edit@istr tag,descriptor,digitalset,engunits,pointsource,pointtype,span,step,typicalvalue,zero,instrumenttag,location1,location2,location3,location4,location5 $($record | ConvertTo-Csv -NoTypeInformation | Select-Object -Skip 1)@ends"@    # Run the PIConfig command (assuming piconfig.exe is in the PATH)    D:/OpNetTags/piconfig.exe -cmd $piconfigCommand    # Log the processed record    $record | Out-File -FilePath $logFile -Append}

The sample input file (Snippet; first 10 records)

ProspectPark_ProspectPark - %Missing,2.01102009_1,,_BLANK,UFL_BKL_ANA,Float32,100,0,50,0,2.01102009_1,1,0,0,2,0ProspectPark_ProspectPark - Blown Fuse Threshold,2.01102015_1,,Amps,UFL_BKL_ANA,Float32,100,0,50,0,2.01102015_1,1,0,0,2,0ProspectPark_ProspectPark - Min Amp Threshold,2.01102016_1,,Amps,UFL_BKL_ANA,Float32,100,0,50,0,2.01102016_1,1,0,0,2,0ProspectPark_ProspectPark - Open NWP Threshold,2.01102014_1,,Perct,UFL_BKL_ANA,Float32,100,0,50,0,2.01102014_1,1,0,0,2,0ProspectPark_ProspectPark - SOCCS MW,2.01102011_1,,MW,UFL_BKL_ANA,Float32,100,0,50,0,2.01102011_1,1,0,0,2,0ProspectPark_ProspectPark - Total Reporting Threshold,2.01102013_1,,Perct,UFL_BKL_ANA,Float32,100,0,50,0,2.01102013_1,1,0,0,2,0RichmondHill_RichmondHill - #Blown Fuses,2.01100805_1,,_BLANK,UFL_BKL_ANA,Float32,100,0,50,0,2.01100805_1,1,0,0,2,0RichmondHill_RichmondHill - #Feeders,2.01100807_1,,_BLANK,UFL_BKL_ANA,Float32,100,0,50,0,2.01100807_1,1,0,0,2,0

Viewing all articles
Browse latest Browse all 653

Trending Articles