Skip to content
Advertisement

Reading Excel file with SQL returns null due to empty column

I am attempting to read in an Excel File from a third party but it falls over and returns null due to empty column.

The file has 50 columns, a blank column and a further 48 columns. I only want the first 50 columns. If I delete or populate the empty column in Excel it works but I need to read 50+ files one after the other, regularly, so opening/deleting/saving isn’t an option.

I did try using specific requests for the columns I wanted but this still returned null. I attempted a single column but again returned null.

Is there a way around the empty column? Even if reading the file in a different way. (I nearly always read in csv files which are a breeze to get into an array and deal with.)

Picture of source data headers enter image description here

Advertisement

Answer

Given that you have no choice but to work with the files in the format provided, the best approach/workaround (rather than manually opening/deleting/saving/closing the files individually) would appear to be to pre-process them using VBA to delete the offending column, before then running your query.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement