Sponsored Content
Special Forums Windows & DOS: Issues & Discussions Split Data in one column into 2 column in Excel using DOS or VBScript Post 302403275 by Franklin52 on Friday 12th of March 2010 02:51:02 AM
Old 03-12-2010
The scriptname should have .vbs as extension, the output goes to the file Outfile:

Code:
Dim filesys, Infile, Outfile, pos

Const ForReading = 1, ForWriting = 2 

file = InputBox("Filename : ")

if file = "" then
  WScript.Quit
end if

Outfile = "Outfile"

Set filesys = CreateObject("Scripting.FileSystemObject")

If NOT filesys.FileExists(file) Then
  msgbox("File " & file & " not found!")
  WScript.Quit
End If 

Set Infile = filesys.OpenTextFile(file, ForReading, True)
Set Outfile = filesys.OpenTextFile(Outfile, ForWriting, True)

do while Infile.AtEndOfStream <> true
  Line = Infile.readline
  pos = instr(Line,",")
  Line = Left(Line, pos - 1) & "|" & Mid(Line, pos + 1)
  Outfile.WriteLine(Line)
loop

Infile.Close
Outfile.Close

Set Infile = Nothing
Set Outfile = Nothing
Set filesys = Nothing

MsgBox("Ready")

Regards
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace column that matches specific pattern, with column data from another file

Can anyone please help with this? I have 2 files as given below. If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value. file1 abc_1 foo1@a .... abc_1 soo2@a ... def_2 soo2@a .... def_2 foo1@a ........ (7 Replies)
Discussion started by: prashali
7 Replies

2. Shell Programming and Scripting

Excel file attachment showing data in single column

Hi All, found similar posts, but not exatcly what i wanted. I have an text file like below and am trying to send mail as an excel file but when i get the excel file as the attachment, all the data is coming in the first column. I need below data in 4 columns. Unix file Name,ID,Trade,Date... (3 Replies)
Discussion started by: robinbannis
3 Replies

3. Shell Programming and Scripting

Compare 2 files and match column data and align data from 3 column

Hello experts, Please help me in achieving this in an easier way possible. I have 2 csv files with following data: File1 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:36:09,JOB_5340 08/23/2012 12:36:14,JOB_5340 08/23/2012 12:36:22,JOB_5350 08/23/2012... (5 Replies)
Discussion started by: asnandhakumar
5 Replies

4. Shell Programming and Scripting

awk to sum a column based on duplicate strings in another column and show split totals

Hi, I have a similar input format- A_1 2 B_0 4 A_1 1 B_2 5 A_4 1 and looking to print in this output format with headers. can you suggest in awk?awk because i am doing some pattern matching from parent file to print column 1 of my input using awk already.Thanks! letter number_of_letters... (5 Replies)
Discussion started by: prashob123
5 Replies

5. Shell Programming and Scripting

Insert data in first column(if blank) from previous line first column

Dear Team I need to insert field(which is need to taken from previous line's first field) in first column if its blank. I had tried using sed but not find the way. Detail input and output file as below. Kindly help for same. INPUT: SCGR SC DEV DEV1 NUMDEV DCP ... (7 Replies)
Discussion started by: jaydeep_sadaria
7 Replies

6. Shell Programming and Scripting

Split column data if the table has n number of column's

please write a shell script Table -------------------------- 1 2 3 a b c 3 4 5 c d e 7 8 9 f g h Output should be like this --------------- 1 2 3 3 4 5 7 8 9 a b c c d e f g h (1 Reply)
Discussion started by: Priti2277
1 Replies

7. Shell Programming and Scripting

Split column data if the table has n number of column's with some record

Split column data if the table has n number of column's with some record then how to split n number of colmn's line by line with records Table --------- Col1 col2 col3 col4 ....................col20 1 2 3 4 .................... 20 a b c d .................... v ... (11 Replies)
Discussion started by: Priti2277
11 Replies

8. Shell Programming and Scripting

Split column when value in column is blank in any row

Hi Experts, In short : Need to split file when field in column 5 is blank and need to generate two file in which column 5 is blank and other in which column 5 has values along with other rows and column data My issue is i am not able to get header for column from raw file into new file which... (1 Reply)
Discussion started by: as7951
1 Replies

9. UNIX for Beginners Questions & Answers

How to insert data into black column( Secound Column ) in excel (.XLSX) file using shell script?

Source Code of the original script is down below please run the script and try to solve this problem this is my data and I want it column wise 2019-03-20 13:00:00:000 2019-03-20 15:00:00:000 1 Operating System LAB 0 1 1 1 1 1 1 1 1 1 0 1 (5 Replies)
Discussion started by: Shubham1182
5 Replies

10. UNIX for Beginners Questions & Answers

How to copy a column of multiple files and paste into new excel file (next to column)?

I have data of an excel files as given below, file1 org1_1 1 1 2.5 100 org1_2 1 2 5.5 98 org1_3 1 3 7.2 88 file2 org2_1 1 1 2.5 100 org2_2 1 2 5.5 56 org2_3 1 3 7.2 70 I have multiple excel files as above shown. I have to copy column 1, column 4 and paste into a new excel file as... (26 Replies)
Discussion started by: dineshkumarsrk
26 Replies
File::RandomAccess(3)					User Contributed Perl Documentation				     File::RandomAccess(3)

NAME
File::RandomAccess - Random access reads of sequential file or scalar SYNOPSIS
use File::RandomAccess; $raf = new File::RandomAccess(*FILE, $disableSeekTest); $raf = new File::RandomAccess($data); $err = $raf->Seek($pos); $num = $raf->Read($buff, $bytes); DESCRIPTION
Allows random access to sequential file by buffering the file if necessary. Also allows access to data in memory to be accessed as if it were a file. METHODS
new Creates a new RandomAccess object given a file reference or reference to data in memory. # Read from open file or pipe $raf = new File::RandomAccess(*FILE); # Read from data in memory $raf = new File::RandomAccess($data); Inputs: 0) Reference to RandomAccess object. 1) File reference or scalar reference. 2) flag set if file is already random access (disables automatic SeekTest). Returns: Reference to RandomAccess object. SeekTest Performs test seek() on file to determine if buffering is necessary. If the seek() fails, then the file is buffered to allow random access. SeekTest() is automatically called from new unless specified. $result = $raf->SeekTest(); Inputs: 0) Reference to RandomAccess object. Returns: 1 if seek test passed (ie. no buffering required). Notes: Must be called before any other i/o. Tell Get current position in file $pos = $raf->Tell(); Inputs: 0) Reference to RandomAccess object. Returns: Current position in file Seek Seek to specified position in file. When buffered, this doesn't quite behave like seek() since it returns success even if you seek outside the limits of the file. $success = $raf->Seek($pos, 0); Inputs: 0) Reference to RandomAccess object. 1) Position. 2) Whence (0=from start, 1=from cur pos, 2=from end). Returns: 1 on success, 0 otherwise Read Read data from the file. $num = $raf->Read($buff, 1024); Inputs: 0) Reference to RandomAccess object. 1) Buffer. 2) Number of bytes to read. Returns: Number of bytes actually read. ReadLine Read a line from file (end of line is $/). Inputs: 0) Reference to RandomAccess object. 1) Buffer. Returns: Number of bytes read. Slurp Read whole file into buffer, without changing read pointer. Inputs: 0) Reference to RandomAccess object. Returns: Nothing. BinMode Set binary mode for file. Inputs: 0) Reference to RandomAccess object. Returns: Nothing. Close Close the file and free the buffer. Inputs: 0) Reference to RandomAccess object. Returns: Nothing. AUTHOR
Copyright 2003-2010 Phil Harvey (phil at owl.phy.queensu.ca) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Image::ExifTool(3pm) perl v5.12.1 2010-01-04 File::RandomAccess(3)
All times are GMT -4. The time now is 01:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy