Use Bat script on CSV to Delete row if column has empty data

August 3, 2017 at 08:10:41
Specs: Windows 7
Hi guys. I'm looking for a bat script to remove certain rows that contain empty cells on Column C

For example, I have the following and need to remove any rows if Meat column has a blank cell.

Fruits Meats Beverages
1 6 1
4 9
2 4 8
3 3

I need it to look like below.

Fruits Meats Beverages
1 6 1
2 4 8


Any ideas? I appreciate any feedback. Note I can't use a Macro or Excel to do this as it messes up the format we use for importing into our data server.

Thanks,
Mr. Pongo


See More: Use Bat script on CSV to Delete row if column has empty data

Reply ↓  Report •

#1
August 4, 2017 at 07:11:54
I don't see any commas.

But maybe everybody else does.

2017-08-04 21:12:45.53 GMT +7

=====================

M2 Get custom script or take private lessons


Reply ↓  Report •

#2
August 4, 2017 at 08:15:38
Yeah, I'm not really sure when this became A Thing™. CSV files are text files, which is why you can entertain the idea of using a batch file, so show us the text, not Excel's sanitized and sanctioned view of your data. The latter's only useful if you want a solution that uses Excel, because the only program that'll give you Excel's view is Excel, and batch can't interface with Excel.

How To Ask Questions The Smart Way


Reply ↓  Report •

#3
August 8, 2017 at 06:17:15
I do apologize for not providing a better example. Here is the text version.

Fruits,Meats,Beverages
1,6,1
4,,9
2,4,8
3,,3

I need it to look like this.
Fruits,Meats,Beverages

1,6,1
2,4,8


Reply ↓  Report •

Related Solutions

#4
August 8, 2017 at 06:19:11
One more thing, it would be Column B that has the blank data not Column C

Reply ↓  Report •

#5
August 8, 2017 at 07:53:39
If it's really only 3 columns, and you only care about the middle column, you can strip out a lot of complexity and end up with:
findstr /v ",," some.csv > new.csv

How To Ask Questions The Smart Way


Reply ↓  Report •

#6
August 9, 2017 at 08:43:09
Thanks for your reply and solution. It's actually 11 columns and sorry it's actually empty data for Column 3. Below is an example with a lot less columns.

Fruits,Meats,Beverages,Alcohol
1,1,2,6
4,9,,1
2,4,4,8
3,3,,11

Need it to look like this

Fruits,Meats,Beverages,Alcohol
1,1,2,6
2,4,4,8

Any ideas?


Reply ↓  Report •

#7
August 9, 2017 at 18:54:43
You are, by your own admission, zero for three in providing an accurate representation of your data. I'm not sure how many chances you have, but I suspect you're swiftly running out.

How To Ask Questions The Smart Way


Reply ↓  Report •

#8
August 10, 2017 at 05:01:16
Sorry but my colleague kept changing the data on me but this is final.

Reply ↓  Report •

#9
August 10, 2017 at 22:54:41
scripting in itself is not inherently dangerous. But to an even greater degree than the sea, it is terribly unforgiving of any carelessness, incapacity or neglect.

Must be them invisible 11 columns. Like the invisible commas when this mess started.

R2 already gave you the line you need.

2017-08-11 12:53:47.09 GMT +7

=====================

M2 Get custom script or take private lessons


Reply ↓  Report •

#10
August 11, 2017 at 06:00:19
I figured it out myself. Thanks for nothing!

Reply ↓  Report •

Ask Question