Reading CSV files using C#

I’m writing a simple import application and need to read a CSV file, show result in a DataGrid and show corrupted lines of the CSV file in another grid. For example, show the lines that are shorter than 5 values in another grid. I’m trying to do that like this: StreamReader sr = new StreamReader(FilePath); … Read more

Sorting a tab delimited file

I have a data with the following format: foo<tab>1.00<space>1.33<space>2.00<tab>3 Now I tried to sort the file based on the last field decreasingly. I tried the following commands but it wasn’t sorted as we expected. $ sort -k3nr file.txt # apparently this sort by space as delimiter $ sort -t”\t” -k3nr file.txt sort: multi-character tab `\\t’ … Read more

How to use mongoimport to import csv

Trying to import a CSV with contact information: Name,Address,City,State,ZIP Jane Doe,123 Main St,Whereverville,CA,90210 John Doe,555 Broadway Ave,New York,NY,10010 Running this doesn’t seem to add any documents to the database: $ mongoimport -d mydb -c things –type csv –file locations.csv –headerline Trace says imported 1 objects, but firing up the Mongo shell and running db.things.find() doesn’t … Read more