Git Product home page Git Product logo

csvvalidator's Introduction

Test-CSVHeader

SYNOPSIS

Test-CSVHeader tests a CSV file to validate all the headers defined in an array are present in the CSV file being tested.

SYNTAX

Set 1

Test-CSVHeader [-Path] <String> [-Headers] <String[]> [-DisallowHeadersWithoutRules] [<CommonParameters>]

DESCRIPTION

The function Test-CSVHeader takes a path to a CSV file as well as an array of headers to validate are present in the CSV file. The switch DisallowHeadersWithoutRules can also be used which will cause the CSV file to be marked invalid if there are extra headers in the CSV file which are not present in the Headers array.

EXAMPLES

EXAMPLE 1

Example of testing a CSV file and marking it as invalid if there are extra headers

C:\PS> Test-CSVHeader -Path "C:\Test\Example.csv" -Headers @("Name","Data") -DisallowHeadersWithoutRules

EXAMPLE 2

Example of testing a CSV file and allowing extra headers (default behavior)

C:\PS> Test-CSVHeader -Path "C:\Test\Example.csv" -Headers @("Name","Data")

PARAMETERS

Path

The path to the CSV file to test. The path to the file is tested by a validation script to ensure the file exists before it is processed.

Type: String
Parameter Sets: Set 1
Aliases: File , FilePath , csv , csvfile

Required: true
Position: 0
Default Value: 
Pipeline Input: False

Headers

An array of headers to ensure are present in the CSV file.

Type: String[]
Parameter Sets: Set 1
Aliases: 

Required: true
Position: 1
Default Value: 
Pipeline Input: False

DisallowHeadersWithoutRules

If this switch is present, a CSV file will be considered to not be valid if it contains headers which are not present in the Headers array. If the switch is not present, then the file is considered valid if there are extra headers in the CSV file not defined by the Headers array.

Type: SwitchParameter
Parameter Sets: Set 1
Aliases: 

Required: false
Position: named
Default Value: 
Pipeline Input: False

<CommonParameters>

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

INPUTS

None

OUTPUTS

System.Management.Automation.PSCustomObject

A custom PSObject which contains the following properties:HeadersInRules,RulesAllPresent,CSVValid,MissingHeaders. HeadersInRules is true if all of the headers in the CSV file are present in the Headers array. If there are extra headers in the CSV file, the property is false. If all of the headers defined in the Headers array are present in the CSV file, then this property is true. If RulesAllPresent is true and DisallowHeadersWithoutRules is not present then even if HeaderInRules is false CSVValid will be true. If however, DisallowHeadersWithoutRules is present and HeadersInRules is false, then the CSV file will be marked as invalid.

NOTES

RELATED LINKS

Generated by: PowerShell HelpWriter 2018 v2.2.41

csvvalidator's People

Contributors

armentpau avatar

Stargazers

 avatar

Watchers

 avatar  avatar

csvvalidator's Issues

Allow for headers to contain aliases

Currently the headers parameters accepts an array of items

$headers = @("OperatingSystem","ServerName","cdrive")

Instead to accomodate options in a header name allow for an array to be inserted

so $headers = @(@("OperatingSystem","OS"),"ServerName",@("cdrive","c"))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.