Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21090

Help to output SQL query to CSV, with a twist!

$
0
0
Hi guys, right now I am writing data to a csv file.
Once I write the file, I send it via ftp to a non windows based device for parsing.

The catch is that the only way I am able to parse the file on this remote device is to point to a specific location in the file.
The proprietary code is a little strange. If you are familiar with C, you know that the scanf() utilize a byte offset, and max byte count in it's syntax.
This proprietary language has a similar syntax for outputting the file read.

So essentially, I have to ensure each line of my CSV file lines writes to 100 bytes each.
Even if I only need 30 bytes of a particular line, the relatively inflexible coding forces that I count to that 100 byte before it will allow me to parse the next line.

This is a problem because right now my CSV files are being output directly from a SWL query, and will vary in their row sizes.

Do you guys have any ideas for how I can somehow compare my output rows to the 100 byte requirement?
If it's less than 100 bytes (which it will almost always be), then I need to add characters. Right now for testing I've been manually adding white space before the carriage return.

Why this 100 bytes? That's a number I came up with to account for the worst case scenario.



My CSV file looks something like this:

Random description that the user can enter to define a specific task or item, 0, 0, 1, 192,168.1.3

The first column is a user defined description. They can write up to 80 bytes for a description.




Any help would be greatly appreciated.

I know I could probably run some sort of file line length size funtion, and then write that way.
But when I have potentially 400+ rows, there must be a more flexible method.



Sorry, I am new to VB and C! PLC programmer trying to expand possibilities.


Thanks!

Viewing all articles
Browse latest Browse all 21090

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>