Related:
- Explain how to copy content from one worksheet to another
- Google sheet right to left - Guide
- Windows network commands cheat sheet - Guide
- Mark sheet in excel - Guide
- How to open excel sheet in notepad++ - Guide
- Little alchemy cheat sheet - Guide
2 responses
SenHu
Posts
15
Registration date
Friday May 22, 2009
Status
Member
Last seen
February 2, 2010
14
Aug 17, 2009 at 11:21 AM
Aug 17, 2009 at 11:21 AM
Hello meljam
If you want to do this automatically without manually opening the spreadsheet program, you can write a script for that. Save the files as CSV (Comma Separated Values) or TSV (Tab Separated Values). Excel will work with both. I will assume TSV.
Here, then, is the synopsis of the problem. We want to copy cell A2 (second row, first column) from C:/file1.csv to C:/file2.csv.
# Script A2.txt
# Read file1.
var str content1 ; cat "C:/file1.csv" > $content1
# Get second row of content1.
var str row2 ; lex -e "2" $content1 > $row2
# Get first column of row2.
var str column1 ; wex -e "1" $row2 > $column1
# We now have the value of cell A2 in $column1. Read file2.
var str content2 ; cat "C:/file2.csv" > $content2
# Extract the first row of content2 unchanged into output.
var str output ; lex -e "1]" $content 2 > $output
# Put in the extracted value of cell A2.
echo "\n" $column1 "\t" >> $output
# Put in the rest of data from content2.
wex -e "[2" $content2 >> $output
# Output is ready. Write it back to file2.
echo $output > "C:/file2.csv"
# Done.
Script is in biterscripting ( http://www.biterscripting.com ) . To try, save the script as C:/Scripts/A2.txt, start biterscripting, enter the following command.
script A2.txt
The script can also be called from the task scheduler, if you want to schedule a monthly task. I am calling the script A2 because, we want to extract cell A2 here. But, you can change the script to extract any other cell, or even multiple cells.
Sen
If you want to do this automatically without manually opening the spreadsheet program, you can write a script for that. Save the files as CSV (Comma Separated Values) or TSV (Tab Separated Values). Excel will work with both. I will assume TSV.
Here, then, is the synopsis of the problem. We want to copy cell A2 (second row, first column) from C:/file1.csv to C:/file2.csv.
# Script A2.txt
# Read file1.
var str content1 ; cat "C:/file1.csv" > $content1
# Get second row of content1.
var str row2 ; lex -e "2" $content1 > $row2
# Get first column of row2.
var str column1 ; wex -e "1" $row2 > $column1
# We now have the value of cell A2 in $column1. Read file2.
var str content2 ; cat "C:/file2.csv" > $content2
# Extract the first row of content2 unchanged into output.
var str output ; lex -e "1]" $content 2 > $output
# Put in the extracted value of cell A2.
echo "\n" $column1 "\t" >> $output
# Put in the rest of data from content2.
wex -e "[2" $content2 >> $output
# Output is ready. Write it back to file2.
echo $output > "C:/file2.csv"
# Done.
Script is in biterscripting ( http://www.biterscripting.com ) . To try, save the script as C:/Scripts/A2.txt, start biterscripting, enter the following command.
script A2.txt
The script can also be called from the task scheduler, if you want to schedule a monthly task. I am calling the script A2 because, we want to extract cell A2 here. But, you can change the script to extract any other cell, or even multiple cells.
Sen
Mar 9, 2018 at 10:19 PM