Skip to content

Instantly share code, notes, and snippets.

@vermorel
Created March 20, 2014 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vermorel/9659850 to your computer and use it in GitHub Desktop.
Save vermorel/9659850 to your computer and use it in GitHub Desktop.
# Replace commas by dots in a very large file (full streaming)
$infile = ls .\MyFile.csv
$outfile = $infile.DirectoryName + "\MyFile.csv.out"
$reader = [System.IO.File]::OpenText($infile.FullName)
$writer = [System.IO.StreamWriter] $outfile
try {
for(;;) {
$line = $reader.ReadLine()
if ($line -eq $null) { break }
# process the line
$writer.WriteLine($line.Replace(",","."))
}
}
finally {
$reader.Close()
$writer.Close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment