Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Formating data
Message
From
22/04/2000 10:04:12
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
22/04/2000 09:30:03
Todd Wolfe
Certified Marketing Services
Kinderhook, New York, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00362485
Message ID:
00362488
Views:
15
>I have a table that has the following fields and data
>
>oldtable
>
>Field_name Data
>Firstname John
>Lastname Smith
>Phone 555-1212
>Firstname Peter
>Lastname Johns
>Phone 555-1252
>
>I would like to change the dat to look like this
>
>newtable
>
>Firstname Lastname Phone
>John Smith 555-1212
>Peter Jones 555-1252
>
>
>
Does anyone have any suggestions as how I can do this.
>
>
>Thanks,
>Todd


Todd,
Your table except first line nicely follows 3 lines per record definition. I would do it with a lowlevel processing :
create table newtable (Firstname c(20), LastName c(20), Phone c(20))
* 20 length is not important - could be changed later or here
handle = fopen("olddata.ext")
=fgets(handle)  && Discard first line
do while !feof(handle)
  lcLine = trim(fgets(handle))
  m.FirstName = substr(lcLine, rat(" ",lcLine)+1)
  lcLine = trim(fgets(handle))
  m.LastName = substr(lcLine, rat(" ",lcLine)+1)
  lcLine = trim(fgets(handle))
  m.Phone = substr(lcLine, rat(" ",lcLine)+1)
  insert into newtable from memvar
enddo
=fclose(handle)
Alternative way:
create table newtable (Firstname c(20), LastName c(20), Phone c(20))create cursor myTransfer (Fname c(12), cData c(20))
append from olddata.ext type sdf
go top
skip
scan while !eof()
 for ix = 1 to 3
   store cData to ("m."+fname)
   skip
 endfor
 insert into newtable from memvar
 skip -1 && Endscan does an implicit skip
endscan
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform