dbTalk Databases Forums  

Basic Program to Import a CSV file

comp.databases.pick comp.databases.pick


Discuss Basic Program to Import a CSV file in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #21  
Old   
Bruce Nichol
 
Posts: n/a

Default Re: Basic Program to Import a CSV file - 06-08-2006 , 11:47 PM






Goo'day, Tony,

On Thu, 08 Jun 2006 18:35:53 -0700, Tony Gravagno
<g6q3x9lu53001 (AT) sneakemail (DOT) com.invalid> wrote:

Quote:
Bruce Nichol wrote:

These sorts of things (advice requests answered more broadly than the
OP - and TG - probably wants) but I see no problems with a bit of
flag-waving, simply bacause the response can be read by anybody, and
it might just trigger something for that somebody in another exercise.

But, as you've discovered, gawdhelpyer if your flag is a different
colout than TG's..... <grin

I think there are a couple bits of confusion here.
Absolutely no confusion on my part at all, mate.

<snip>

And feel free to react howsoever you like. I'm not listening....
I've got my fingers in my ears!

And see this here ---> <grin> It means that whatever was said was
said with a good deal of levity... you know, laughter, chortling,
sniggering, et al... Life's too short, mate.

Plus, I'm astounded that anybody takes any notice of anything I
say.... neither of two wives from my past ever did..... <more grin>


Regards,

Bruce Nichol
Talon Computer Services
ALBURY NSW Australia

http://www.taloncs.com.au

If it ain't broke, fix it until it is....


Reply With Quote
  #22  
Old   
bruce ackman
 
Posts: n/a

Default Re: Basic Program to Import a CSV file - 06-09-2006 , 06:44 AM






That sounds like a great tool. With the risk of sounding like Tom, I'll
mention that I use OpenOffice, but I could just save my OO spreaadsheets
as Excel files before using ExcelExport. I use Accuterm to import CSV's
to D3 and I'm surprised no one has mentioned that. It's easy,
effective, and not to expensive. Unlike some of us, I don't mind paying
for things that make me more productive or make my life easier <g>.

Bruce

Tony Gravagno wrote:
Quote:
To get the CSV from an XLS file in the first place, you can use my
ExcelExport program. It's completely free, no binding to mv.NET or
any other for-fee communications product.
http:// removethisNebula-RnD.com/freeware/
The advantage here is that it exports all worksheets into unique CSV
files. See the related README doc.

Once you have the CSV files you can use code like what Ross suggests.
ExcelExport ensures that all fields are wrapped in quotes, so the code
would need to remove beginning and trailing quotes, and then convert
all embedded instances of two consecutive quotes into one double
quote. This just adds two more lines of code to what Ross provided.

BTW, the code below breaks fields based on tabs but your data example
shows fields are delimited by commas. You say your code doesn't
include commas or quotes but as soon as you hard-code that "fact" into
your program you'll find someone has inserted quotes or commas either
on purpose or on accident. Do yourself a favor an assume there may be
quotes and commas. This sort of pro-active coding is much better than
reactive "help, it just broke" programming.

Your need for CSV to MV import is really just about simple string
manipulation. One of the reasons why MV is so popular among us fans
is that MV BASIC is superb for this sort of operation - and it's very
easy to do. If you have any other programmers on staff they should be
able to work this out, or if you need something very specific there
are many people here who could write something for you, perhaps for
some low fee for their time.

Within the next week I intend to enhance the ExcelExport (with a
separate executable) to allow direct writing to an MV file exactly as
you have described. While this utility will be free, the
functionality requires mv.NET which has a small licensing fee. If
you're interested, let me know and you'll have this solution quickly
with no coding effort, full support, and you'll be able to use the new
connectivity to do a lot more.

HTH
Tony
TG@ removethisNebula-RnD.com


"Ross Ferris" wrote:


To make your life easier, I'd open the file in Excel, then save as a
tab delimited file --> Excel does this well, and you will not have any
"issues" to deal with. Next, pop your file into a type 1/19 file
(directory) so that it can be accessed.

I'll assume that this file is called "DOS", the source item is called
"SOURCE" and your target file is deals.mv, and that there isn't a
"header" record for the SOURCE item


Code would be :

OPEN "","DOS" TO DOS.FV ELSE STOP "OPEN DOS FAILED"
OPEN "","DEALS.MV" TO DEALS.FV ELSE STOP "OPEN TARGET FAILED"
READ DOS.REC FROM DOS.FV,"SOURCE" ELSE STOP "SOURCE READ FAILED"

* MANY WAYS TO IMPROVE THIS LOOP, BUT FOR SMALL
* ITEMS THIS IS FINE

NOL = DCOUNT(DOS.REC,@FM) ;* number of lines (new
records)

FOR I = 1 TO NOL
ALINE = DOS.REC<I> ;* get a raw
line
CONVERT CHAR(9) TO @FM IN ALINE ;* put into UV format
WRITE ALINE ON DEALS.FV, ALINE<1> ;* write it out
NEXT I

STOP "ALL DONE"


hth



Wytevette wrote:

Hello,

My system is Universe v10 running on Windows 2003
I have a CSV file called deals.csv that I would like to make into a
pick file called deals.mv

I have been searching the group, trying to help myself, but honestly
don't have the experience to make this work.

I was hoping I could obtain some source code that would permit me to
manually copy and paste the deals.csv file into my C:\IBM\UV folder,
then when I run the program, it creates a new PICK file called
deals.mv.

Each row of the CSV file would be a record in the deals.mv file, with
the name of the record being the very first field of each row in the
deals.csv file.

For example, the first row of deals.csv is
123456,starburst,bx,9.99,7950000232

I would like to turn that into a record in the deals.mv file entitled
123456 with the contents of the record being:

0001: 123456
0002: starburst
0003: bx
0004: 9.99
0005: 7950000232


From what I have read so far, this can be difficult if the CSV has
abnormal characters, such as line feeds and quote marks in the fields.

I believe my CSV file is "clean" and does not have any quotes or LF/CR
in them. There are, however, spaces in some of the fields.

Thank you in advance for any tips or assistance.

Phil



Reply With Quote
  #23  
Old   
murthi
 
Posts: n/a

Default Re: Basic Program to Import a CSV file - 06-12-2006 , 09:05 AM



Tony, I think you're being way too reticent and terse. Would you explain
your position in a little more detail? And also tell us what exactly .Net
can do for us again?

Chandru Murthi

"Tony Gravagno" <g6q3x9lu53001 (AT) sneakemail (DOT) com.invalid> wrote

Quote:
Bruce Nichol wrote:

These sorts of things (advice requests answered more broadly than the
OP - and TG - probably wants) but I see no problems with a bit of
flag-waving, simply bacause the response can be read by anybody, and
it might just trigger something for that somebody in another exercise.

But, as you've discovered, gawdhelpyer if your flag is a different
colout than TG's..... <grin

I think there are a couple bits of confusion here.

First, I made the mistake of acting on an immediate assumption that
the OP was using Excel. That prompted a suggestion that there was an
easy and free way to export CSV from Excel in manner that 1) would be
easily parsable with BASIC code, and 2) would handle a very common
issue with exporting CSV from Excel which is providing for multiple
worksheets. As I started my last post, I admit this was a silly
assumption which many of us make from time to time. But we see so
many requests for Excel/CSV processing here that I'm sure the info
would be of use to someone one of these days.

Second (again based on the original faulty assumption), I mentioned a
direct method of extracting from Excel on any system, and pumping the
data directly into any MV environment on any local or remote system.
It was over and above what the OP asked for, but it did follow more
helpful advice, and might be of interest to someone else. I'm often
enthusiastic to get people to understand what's possible with the
tools we have available and frequently add some insight to basic
advice. QM certainly doesn't offer anything like this, so I was
surprised to have my offering criticized with blatent lies while the
proposed alternative suggests nothing less than a purchase of a new
for-fee DBMS.

QM hadn't even been mentioned when Tom jumped in with his comments
about my post, so I don't know how you're turning this into a flag
waving thing. Many of us have differing opinions here and alternative
products and suggestions. I'm upset with the way he continually feels
a need to distort the truth about what I've said or done even when
he's talking about something completely different. Feel free to
disagree with what I say but there's no need to lie in order to
present a different view. If there is any question about what I'm
talking about, just look at our last exchanges and at the last blow up
we had over the exact same thing some months ago when he says I said
crap that I didn't say.

You guys tend to buzz like hornets in your support of QM as though I'm
disturbing the nest by mentioning Microsoft - and yet I haven't said
anything about QM itself, so why the aggressive defensive position?

Once again the real problem is that I react to this. Tom's incoherent
response to my last note is just another lure intended to get me to
try to correct him again. Anyone who puts the comments up side by
side will be able to see just how irrational the individual sentences
are when taken in context. We all have more important things to do,
let's move on.

T



Reply With Quote
  #24  
Old   
frosty
 
Posts: n/a

Default Re: Basic Program to Import a CSV file - 06-12-2006 , 02:21 PM



murthi wrote:
Quote:
Tony, I think you're being way too reticent and terse. Would you
explain your position in a little more detail? And also tell us what
exactly .Net can do for us again?

Chandru Murthi
Chuck, you left off the smiley face...
Tony might think you're serious! =`;^>

--
frosty




Reply With Quote
  #25  
Old   
murthi
 
Posts: n/a

Default Re: Basic Program to Import a CSV file - 06-12-2006 , 06:44 PM



My keyboard don't have 'em. Remember I'm a Luddite.

"frosty" <frostyj (AT) bogus (DOT) tld> wrote

Quote:
murthi wrote:
Tony, I think you're being way too reticent and terse. Would you
explain your position in a little more detail? And also tell us what
exactly .Net can do for us again?

Chandru Murthi

Chuck, you left off the smiley face...
Tony might think you're serious! =`;^

--
frosty




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.