Computing.Net > Forums > Programming > Need help in transposing rows

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Need help in transposing rows

Reply to Message Icon

Name: yuanhe
Date: February 16, 2009 at 00:19:05 Pacific
OS: Windows XP
CPU/Ram: 1GB
Subcategory: C/C++
Comment:

Hi guys,

currently i have a list of over 6000 contact of info in this form below

Name : tom
address : 49 cedar point
state : ohio
COuntry : USA
Name : jerry
address : 32 cedar point
state : ohio
COuntry : USA
Name : henry
address : 23 washinton
state : LA
COuntry : USA


How do i transpose it into this format in the fastest way?

Name Address state Country
Tom 49 cedar.. Ohio USA
Jerry 32 cedar.. Ohio USA
Henry 23 washin.. LA USA


I am able to do it for a few rows. However is there any faster way for me to repeat this process as i have over 1000 contacts?

Many thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: Holla
Date: February 16, 2009 at 03:37:34 Pacific
Reply:

yuanhe,

Try this. Assumption is that all new entries start with the tag "Name :" (note the space after 'Name' before the ':'.
adrs.txt is the input file and outAdrs.txt is the output file.

setlocal enabledelayedexpansion
for /f "delims=: tokens=1,2*" %%I in (adrs.txt) do (
if "%%I"=="Name " echo. >> outAdrs.txt
set /p t=%%J <nul >> outAdrs.txt
)

--
Holla.


0

Response Number 2
Name: Mechanix2Go
Date: February 16, 2009 at 04:01:26 Pacific
Reply:

@echo off & setLocal EnableDelayedExpansion

> newfile echo Name Address state Country

for /f "tokens=1* delims=: " %%a in (myfile) do (
set /a N+=1
set v!N!=%%b
if !N! equ 4 (
>> newfile echo !v1! !v2! !v3! !v4!
set N=0
)
)


=====================================
If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Need help in transposing rows

if u Need help in VB email me www.computing.net/answers/programming/if-u-need-help-in-vb-email-me/1201.html

RE-POST: Need help in C program... www.computing.net/answers/programming/repost-need-help-in-c-program/4285.html

I need help in c plzzz www.computing.net/answers/programming/i-need-help-in-c-plzzz/529.html