How to read a CLOB file and select only one of the node
i have table with one of it's datatyp as CLOB, i need to read one particular node alone,
Ex
Table tesxml has two columnd id,xml and the xml field is a CLOB which has data as shown below.
<?xml version="1.0" encoding="UTF-8"?>
<alert>
<type0 comment="section in XSL component" name="Initial Information">
<details>
<Priority>0001</Priority>
<Date>2010-06-29</Date>
<Initial_Information></Initial_Information>
</details>
</type0>
</alert>now i need to select id,<Date value(from xml)>,<comment value>
o/p should look like
0000,2010-06-29,section in XSL componenti tried these queries but i am doing something wrong with the syntax..
SELECT alert_internal_id,EXTRACTVALUE(VALUE(c), '/Date') datee
FROM (SELECT id,xmltype(xml) xml FROM tesxml),
table(XMLSEQUENCE(EXTRACT(xml, '/alert/type0/details/'))) c;
select dbms_lob.read(HTML_FILE_KEY,alert,type0,details,Date) from alerts
Depakjan wrote:
No that is not the case if i just remove the where statement it's workingWell, based on your query, you don't seem to have a repeating group, so I'm guessing your XML looks something like the following:
SQL> ed
Wrote file afiedt.buf
1 with alerts as (select 1 as alert_internal_id,
2 '<alert>
3 <tab0 comment="bob">
4 <details>
5 <Priority>1234</Priority>
6 </details>
7 </tab0>
8 <type0>
9 <details>
10 <DateVRUClaimInitiated>01/02/2010</DateVRUClaimInitiated>
11 </details>
12 </type0>
13 </alert>' as xml from dual)
14 --
15 select alert_internal_id,x.* from alerts, xmltable ('.' passing XMLTYPE(xml)
16 columns prio varchar2 (5) path '/alert/tab0/details/Priority',
17 dt varchar2 (15) path '/alert/type0/details/DateVRUClaimInitiated',
18 type_comment varchar2 (25) path '/alert/tab0/@comment') x
19* where x.dt is not null
SQL> /
ALERT_INTERNAL_ID PRIO DT TYPE_COMMENT
1 1234 01/02/2010 bobHowever, let's assume you do have a repeating group of alerts (I'll achieve that by putting them inside a "root" element), and I'll set one of them so there is no dt returned...
SQL> ed
Wrote file afiedt.buf
1 with alerts as (select 1 as alert_internal_id,
2 '<root>
3 <alert>
4 <tab0 comment="bob">
5 <details>
6 <Priority>1234</Priority>
7 </details>
8 </tab0>
9 <type0>
10 <details>
11 <DateVRUClaimInitiated>01/02/2010</DateVRUClaimInitiated>
12 </details>
13 </type0>
14 </alert>
15 <alert>
16 <tab0 comment="jim">
17 <details>
18 <Priority>2222</Priority>
19 </details>
20 </tab0>
21 <type0>
22 <details>
23 <DateVRUClaimInitiated />
24 </details>
25 </type0>
26 </alert>
27 </root>' as xml from dual)
28 --
29 select alert_internal_id,x.* from alerts, xmltable ('root/alert' passing XMLTYPE(xml)
30 columns prio varchar2 (5) path '/alert/tab0/details/Priority',
31 dt varchar2 (15) path '/alert/type0/details/DateVRUClaimInitiated',
32 type_comment varchar2 (25) path '/alert/tab0/@comment') x
33* where x.dt is not null
SQL> /
ALERT_INTERNAL_ID PRIO DT TYPE_COMMENT
1 1234 01/02/2010 bob
SQL>That works ok for me. Database = 10.2.0.1
What version are you on?
Similar Messages
-
How to read a text file and write text file
Hello,
I have a text file A look like this:
0 0
0 A B C
1 B C D
2 D G G
10
1 A R T
2 T Y U
3 G H J
4 T H K
20
1 G H J
2 G H J
I want to always get rid of last letter and select only the first and last line and save it to another text file B. The output should like this
0 A B
2 D G
1 A R
4 T H
1 G H
2 G H
I know how to read and write a text file, but how can I select the text when I am reading a text file. Can anyone give me an example?
Thank youIf the text file A look like that
0 0
0 3479563,41166 6756595,64723 78,31 1,#QNAN
1 3479515,89803 6756588,20824 77,81 1,#QNAN
2 3479502,91618 6756582,6984 77,94 1,#QNAN
3 3479516,16334 6756507,11687 84,94 1,#QNAN
4 3479519,14188 6756498,54413 85,67 1,#QNAN
5 3479525,61721 6756493,89255 86,02 1,#QNAN
6 3479649,5546 6756453,21824 89,57 1,#QNAN
1 0
0 3478762,36013 6755006,54907 54,8 1,#QNAN
1 3478756,19538 6755078,16787 53,63 1,#QNAN
2 0
3 0
N 0
I want to read the line that before and after 1 0, 2 0, ...N 0 line to arraylist. I have programed the following code
public ArrayList<String>save2;
public BufferedWriter bufwriter;
File writefile;
String filepath, filecontent, read;
String readStr = "" ;
String[]temp = null;
public String readfile(String path) {
int i = 0;
ArrayList<String> save = new ArrayList <String>();
try {
filepath = "D:\\thesis\\Material\\data\\CriticalNetwork\\test3.txt";
File file = new File(filepath);
FileReader fileread = new FileReader(file);
BufferedReader bufread = new BufferedReader(fileread);
this.read = null;
// read text file and save each line content to arraylist
while ((read = bufread.readLine()) != null ) {
save.add(read);
// split each arraylist[i] element by space and save it to String[]
for(i=0; i< save.size();i++){
this.temp = save.get(i).split(" ") ;
// if String[] contain N 0 such as 0 0, 1 0, 2 0 then save its previous and next line from save arraylist to save2 arraylist
if (temp.equals(i+"0")){
this.save2.add(save.get(i));
System.out.println(save2.get(i));
} catch (Exception d) {
System.out.println(d.getMessage());
return readStr;
My code has something wrong. It always printout null. Can anyone help me?
Best Regards,
Zhang -
Hello,
I have a text file and each line contains random text followed by an IP address as follows.
some text....172.30.25.30
some text.....172.30.85.10
some text..172.30.25.35
some text.......172.30.85.11
some text....172.30.15.1
some text...172.30.15.2
some text.......172.10.1.1
some text...172.20.4.2
some text..172.10.1.2
some text.....172.20.5.1
I'd like to create an output file which has only one entry for each unique entry in the file where either the first 2 or 3 octets are unique as follows:
Output File
172.30.25
172.30.85
172.30.15
172.10.1
172.20
Any suggestions are appreciated!
Thanks for your help! SdeDotThanks mjolinor. Works great!
Two questions.
1. Could you plz suggest how this could be modified so this code would read the file in or accept it from the pipeline instead of wrapping the (@' around the data?
2. Could you plz briefly describe some of the details of the code so I can further research and understand.
Thanks for your help.
Thanks for your help! SdeDot
1. It already reads in the file. The (@' .. '@) bits are just there to create a file using your test data to demonstrate that it works.
2. Not user what kind of "details" you want. There really isn't much there, and get-help on the cmdlets used should provide information on what's going on with them in that script.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " " -
How To read lib*.so files and verbose its content
Hi
Is there any command with which we can read shared library files and see whats its contents are i.e. whats are the functions available inside it and how its control flow.
Regards
JeetI know of none that shows flow control but you can do a man against nm(1) to see what is in the library (nm libc.so.1).
-
How to read from excel file and write it using implicit jsp out object
our code is as below:Please give us proper solution.
we are reading from Excel file and writing in dynamicaly generated Excel file.it is writing but not as original excel sheet.we are using response.setContentType and response.setHeader for generating pop up for saveing the original file in to dynamically generated Excel file.
<%@ page contentType="application/vnd.ms-excel" %>
<%
//String dLoadFile = (String)request.getParameter("jspname1");
String dLoadFile = "c:/purge_trns_nav.xls" ;
File f = new File(dLoadFile);
//set the content type(can be excel/word/powerpoint etc..)
response.setContentType ("application/msexcel");
//get the file name
String name = f.getName().substring(f.getName().lastIndexOf("/") + 1,f.getName().length());
//set the header and also the Name by which user will be prompted to save
response.setHeader ("Content-Disposition", "attachment; filename="+name);
//OPen an input stream to the file and post the file contents thru the
//servlet output stream to the client m/c
FileInputStream in = new FileInputStream(f);
//ServletOutputStream outs = response.getOutputStream();
int bit = 10;
int i = 0;
try {
while (bit >= 0) {
bit = in.read();
out.write(bit) ;
} catch (IOException ioe) { ioe.printStackTrace(System.out); }
out.flush();
out.close();
in.close();
%>If you want to copy files as fast as possible, without processing them (as the DOS "copy" or the Unix "cp" command), you can try the java.nio.channels package.
import java.nio.*;
import java.nio.channels.*;
import java.io.*;
import java.util.*;
import java.text.*;
class Kopy {
* @param args [0] = source filename
* args [1] = destination filename
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println ("Syntax: java -cp . Kopy source destination");
System.exit(1);
File in = new File(args[0]);
long fileLength = in.length();
long t = System.currentTimeMillis();
FileInputStream fis = new FileInputStream (in);
FileOutputStream fos = new FileOutputStream (args[1]);
FileChannel fci = fis.getChannel();
FileChannel fco = fos.getChannel();
fco.transferFrom(fci, 0, fileLength);
fis.close();
fos.close();
t = System.currentTimeMillis() - t;
NumberFormat nf = new DecimalFormat("#,##0.00");
System.out.print (nf.format(fileLength/1024.0) + "kB copied");
if (t > 0) {
System.out.println (" in " + t + "ms: " + nf.format(fileLength / 1.024 / t) + " kB/s");
} -
How to read a CSV file and Insert data into an Oracle Table
Hi All,
I have a Clob file as a in parameter in my PROC. . File is comma separated.need procedure that would parse this CLOB variable and populate in oracle table .
Please let me some suggestions on this.
Thanks,
Chandra Rjeneesh wrote:
And, please don't "hijack" 5 year old thread..Better start a new one..I've just split it off to a thread of it's own. ;)
@OP,
I have a Clob file as a in parameter in my PROC. . File is comma separated.need procedure that would parse this CLOB variable and populate in oracle table .You don't have a "clob file" as there's no such thing. CLOB is a datatype for storing large character based objects. A file is something on the operating system's filesystem.
So, why have you stored comma seperated data in a CLOB?
Where did this data come from? If it came from a file, why didn't you use SQL*Loader or, even better, External Tables to read and parse the data into structured format when populating the database with it?
If you really do have to parse a CLOB of data to pull out the comma seperated values, then you're going to have to write something yourself to do that, reading "lines" by looking for the newline character(s), and then breaking up the "lines" into the component data by looking for commas within it, using normal string functions such as INSTR and SUBSTR or, if necessary, REGEXP_INSTR and REGEXP_SUBSTR. If you have string data that contains commas but uses double quotes around the string, then you'll also have the added complexity of ignoring commas within such string data.
Like I say... it's much easier with SQL*Loader of External Tables as these are designed to parse such CSV type data. -
How to read in a file and change the column attributes
Hi,
I'm new to java and i'm stuggling to find a way to read in a text file and perform calculations on the data, such as to normalise it.
What in want to do is normalise the data by finding the greatest value in a column and then divide all the other values in the column with that value.
I know how to read a file in and store each line in a vector but for this problem i think i need to store each column in an array, but i'm not sure how to do this.
Can anyone help please?
ThanksHi,
I'm new to java and i'm stuggling to find a way to
read in a text file and perform calculations on the
data, such as to normalise it.
What in want to do is normalise the data by finding
the greatest value in a column and then divide all
the other values in the column with that value.
I know how to read a file in and store each line in a
vector but for this problem i think i need to store
each column in an array, but i'm not sure how to do
this.
Can anyone help please?
ThanksI think this should work but I wrote it out without completely thinking about it (hopefully to get things started).
So if you had this:
age height earnings
0 2 100
1 3 50
2 1 0
For the age column you'd take 2 as the largest and then divide 0 and 1 by two to get 0, .5.
First build up test files that seperate the columns in different ways. With spaces, tabs, and the ASCI Control character for null ( I think it's 0 ). Your program should detect
numbers and spaces, tabs control character, commas and periods (for money). Because numbers don't have spaces it should be easy to keep track of which column
you're in.
Store each line into a 3D String array with each index containing a String built up from the chars scanned in on each line, when a blank area is found followed by another
number iterate the column index. When you come to the end of the line set column == 0 and row+1.
private String[][][] test = new String[2][6][1];
20 3 11 14 44 0
4 5 7 80 91 49
test[0][0][0] would be row 1 col 1 value 1 ((20))
test[0][1][0] would be r1, c2, v1 ((3))
test[1][0][0] would be r2, c1, v1 ((4))
test[1][2][0] would be r2, c3, v1 ((7))
test[1][5][0] would be r2, c6, v1 ((49))
package source.Final;
import javax.swing.*;
import java.io.*;
public class S7
public static void main(String[] args)
getContents();
System.exit(0);
public static void getContents()
String lineSep = System.getProperty("line.separator");
char c = ' ';
int iterator = 0;
int i = 0;
int charNum = 1;
int lineCount = 1;
//declared here only to make visible to finally clause
BufferedReader input = null;
BufferedWriter out = null;
try {
String line = null;
* This implementation reads / writes one line at a time
* using the buffered reader / writer Java classes.
input = new BufferedReader( new FileReader( "C:\\Scan file test\\Read\\test1.txt" ));
out = new BufferedWriter( new FileWriter( "C:\\Scan file test\\Read\\test2.txt" ));
//input = new BufferedReader( new FileReader( "C:\\Scan file test\\Read\\booked_policies1.txt" ));
//out = new BufferedWriter( new FileWriter( "C:\\Scan file test\\Write\\booked_policies1.txt" ));
//input = new BufferedReader( new FileReader( "C:\\Scan file test\\Read\\booked_policies2.txt" ));
//out = new BufferedWriter( new FileWriter( "C:\\Scan file test\\Write\\booked_policies2.txt" ));
//input = new BufferedReader( new FileReader( "C:\\Scan file test\\Read\\booked_policies3.txt" ));
//out = new BufferedWriter( new FileWriter( "C:\\Scan file test\\Write\\booked_policies3.txt" ));
out.write( "Character\tLine Number\tCharacter Number\tAscii Value" + lineSep );
while (( line = input.readLine()) != null)
i = 0;
charNum = 1;
iterator = 0;
while( i < line.length() )
c = line.charAt(iterator);
if( (int)c == 0 || (int)c == 9 )
break;
else if( c >= '[' && c <= '_')
{out.write( "["+c+"]\t\t"+"["+lineCount+"]\t\t"+"["+charNum+"]\t\t\t"+"["+(int)(c)+"]"+lineSep );}
else if( c < ' ' )// && (int)c != 0 && (int)c != 9 )
{out.write( "["+c+"]\t\t"+"["+lineCount+"]\t\t"+"["+charNum+"]\t\t\t"+"["+(int)(c)+"]"+lineSep );}
else if( c > ';' && c <= '@' && c != '=')
{out.write( "["+c+"]\t\t"+"["+lineCount+"]\t\t"+"["+charNum+"]\t\t\t"+"["+(int)(c)+"]"+lineSep );}
else if( c >= '!' && c < '"' )
{out.write( "["+c+"]\t\t"+"["+lineCount+"]\t\t"+"["+charNum+"]\t\t\t"+"["+(int)(c)+"]"+lineSep );}
else if( c > 'z' && c < '~' )
{out.write( "["+c+"]\t\t"+"["+lineCount+"]\t\t"+"["+charNum+"]\t\t\t"+"["+(int)(c)+"]"+lineSep );}
else if( c == '%' )
{out.write( "["+c+"]\t\t"+"["+lineCount+"]\t\t"+"["+charNum+"]\t\t\t"+"["+(int)(c)+"]"+lineSep );}
else if( c > '~' )
{out.write( "["+c+"]\t\t"+"["+lineCount+"]\t\t"+"["+charNum+"]\t\t\t"+"["+(int)(c)+"]"+lineSep );}
charNum += 1;
iterator += 1;
i++;
lineCount += 1;
catch (FileNotFoundException ex) {ex.printStackTrace(); System.out.println("File not found.");}
catch (IOException ex){ex.printStackTrace(); System.out.println("IO Error.");}
finally{ try{ if( input != null ) input.close(); if( out != null ) out.close();}
catch (IOException ex){ex.printStackTrace(); System.out.println("IO Error #2.");}
} -
How to read an html file and replace a text using text_io
hi,
i want ro read an html file using text_io and replace a particular text with a new text
eg: i want to replace a text called "data.js" and with "maps.js"
how do i do this?You have to write your own code to do that. TEXT_IO is just a low level text file interface.
You need to read in all the text, save it in some internal format (array of varchar2's maybe or in the DB) and then perform a search on the text you have read in, find out where the instances of "data.js" are located and substitute them with "maps.js" After that you need to write to a new file and delete the old one. There is no way to search and replace inside the existing file (what's sometimes referred to as 'in-place' substitution).
See the help section called About the TEXT_IO package for an overview of how it works and some code examples. -
How to read an ascii file and record data in a 2d array
HI everyone,
I have an experimental data file in ascii format. It contains 10 data sets.
I'm trying to read the ascii file and record data in a 2d array for further analysis,
but I still could not figure it out how to do it.
Please help me to get this done.
Here I have attaced the ascii file.
-Sam
Attachments:
data.asc 123 KB
2015-01-27_18-01-31_fourier_A2-F-abs.zip 728 KBGot it!
Thank you very much !
-Pamsath -
How to Read from two file and write to another file --Please help !!
Hi all,
Please suggest me where i'm goin goin wrng.
I have 2 flat files. one of them is the main file(Ann.dat) has a about 150,000 lines (each line has unique ID from 00001 to 45000) of data and the the other(Miss.dat) has a just a list of IDs that are no longer in use & have to be deleted from the first file(NewAnn.dat). (Note that Ann.dat is a tab delimitted file and Miss.dat is just a list of all invalid IDs)
Below is my code. It doesn't do what I'm supposed to. Please suggest me or help me with a code to do it. What I'm trying to do is read each of the lines from the 2 files compare the ID in ann.dat with all the IDs in Miss.dat & if it doesn't match with the ID in Miss.dat write the whole line to NewAnn.dat. And do the rest with all the lines in Ann.dat.
It could be a real dumb question. since i'm not a software professional, I consider myself to be newbie to programming. I desperately need your help.
import java.io.*;
import java.util.*;
public class anntemp{
public static void main(String[] args)
String keyAnn ="";
String keyMis="";
String recAnn =null;
String recMis =null;
try{
FileReader fr=new FileReader("C:\\Tom\\Ann.dat");
BufferedReader br=new BufferedReader(fr);
int couter=0;
while ((recAnn = br.readLine())!=null)
couter++;
keyAnn = recAnn.substring(0, recAnn.indexOf("\t"));
FileReader fr1=new FileReader("C:\\Tom\\Miss.dat");
BufferedReader br1=new BufferedReader(fr1);
while((recMis = br1.readLine())!=null){
keyMis = recMis.substring(0, recMis.indexOf("\t"));
if(keyAnn.equals(keyMis)){
FileWriter fw=new FileWriter("C:\\Tom\\NewAnn.dat",true);
BufferedWriter bw=new BufferedWriter(fw);
PrintWriter pw=new PrintWriter(bw);
StringBuffer writeValue = new StringBuffer();
writeValue.append(recAnn);
pw.println(writeValue.toString());
pw.flush();
}catch (Exception expe){
System.out.println("In Exception ");
expe.printStackTrace();
Thank you all in advance,
brI think you need to close the files when you are done in the inner loop. Plus I think you'll be overwritting the file in the inner loop if more than one match. It might be easier to read the unused id file into a map at the start, and then loop up the id's from the master file in the map. You can put the unused id's in as the keys, and a Boolean.TRUE as the value (value won't matter). Then just check if the map contains the key for the id read from the master file. That should cut down on disk activity. This assumes the unused id file is smallish.
-
How to read a text file and only output every other line?
I am just writing a program that reads a file but outputs only every other line. Any ideas...please? thanks
I'd start with something like this and expand on it as you go:
File file = <whatever>;
BufferedReader in = null;
try {
in = new BufferedReader(new FileReader(file));
int i = -1;
for (String line = null; (line = in.readLine()) != null; ) {
if ((++i % 2) == 0) {
System.out.println(line);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
}Shaun -
How to read a txt file and update DB table
I have to read a table which has some entries in it as plain text file, then I should update my table if the table entries and the data in text file are NOT MATCHING o.w. keep the table entry as it is
It will helps to u
data : begin of t_temp occurs 0,
text(256),
end of t_temp.
data : s_file type string.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-S01.
PARAMETER: P_FILE LIKE RLGRAP-FILENAME.
SELECTION-SCREEN : END OF BLOCK B1.
clear s_file.
move p_file to s_file.
uploade SOURCE file to t_tab1
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = s_file
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = t_temp
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Text deleted by Moderator. Do NOT request points
Regards
Saimedha -
How to read an Excel File AND SEND TO GENERATOR
Hi
I want send the datas from Exel file to my device, I have one part in mu code which can read my data from exel but I don t know how can I send this data to ny divice?
I really nead your suggestion, please.
I attached my code also my Exel file.
Attachments:
DG5071.xlsx 1841 KB
Rigol Generator.vi 52 KBHello vsa,
I checked the specifications of this Function Arbitrary Waveform Generator and I found that it is GPIB complaint. Instruments with GPIB protocol can be controlled using GPIB commands, but each instrument could have different GPIB commands. Despite this, most providers have "standard" commands among its products.
I checked some documentation and found a help file that describes the GPIB commands used by this device, so the options are:
1. Wait for someone to develop an Instrument Driver for this instrument.
2. Check if you find any other Function Arbitrary Waveform Generator of the same brand that uses the same commands and for which there is already an instrument driver.
3. Create your own instrument driver.
If you choose option 3 I share with you the following links that you may find useful:
Developing LabVIEW Plug and Play Instrument Drivers:
http://www.ni.com/white-paper/3271/en/
Connecting Instruments via GPIB:
http://www.ni.com/getting-started/set-up-hardware/instrument-control/gpib-connect
GPIB Instrument Control Tutorial:
http://www.ni.com/white-paper/2761/en/
Using IVI Drivers in LabVIEW:
http://www.ni.com/white-paper/4556/en/
Instrument Control in LabVIEW Tutorial:
http://www.ni.com/white-paper/3511/en/
Best regards.
David P.
National Instruments
Applications Engineer
www.ni.com/soporte
Attachments:
DG5000 Programming Guide.zip 907 KB -
How to read from input file and pass to script
How can I get rid of the hard coded PATH statement and feed script based upon text file input.
Input is contained in a file..
'C:\cntprocess\ called sistemfolder.txt that has 2 fields folder
then shortname.
example:
C:\cntprocess\REW1___1~Rew1
C:\cntprocess\REW2___1~Rew2
I want the first part in each record passed to script for processing
C:\cntprocess\REW1___1
C:\cntprocess\REW2___1
Pass those values to this Script: I want values from above passed to the $Path
$path='C:\Sistemi\'
get-childitem -path $path *.spx | % {
" Starting File Process....." >> $path\sistem.log
$PDate = get-date
$date = get-date -uformat "_%d_%m_%Y_%H%M%S.bak"
#"Set backup date to $date" >> $path\sistem.log
$newname=($_.fullname -replace ".spx",$date)
$file = [System.IO.Path]::GetFileNameWithoutExtension($_.fullname)
"File backup name is $newname" >> $path\sistem.log
Rename-Item $_.fullname $newname
"Renamed file to $newname" >> $path\sistem.log
$lines = get-content $newname
foreach ($line in $lines)
$line + " " + [System.IO.Path]::GetFileNameWithoutExtension($_.fullname) | Out-File "$path\sistem.csv" -append
Write-Host $_.fullname
"Files Processed on $PDate are $newname " >> $path\sistem.log
Thanks.OK, I was mistaken a bit on what I originally told you. After you run the command of
$myFile = Import-Csv -Delimiter '~' -Path $path -Header Path, ShortName
$myFile is actually an array of PSCustomObjects, so you cannot access it like $myFile.Path, you will actually have to loop through the $myFile first, so try changing your script to be the following and see if that helps any
param
[string]$path
$myFiles = Import-Csv -Delimiter '~' -Path $path -Header Path, ShortName
# Then you can call it like so
$myFiles.Path #Returns just the path
$myFiles.ShortName # Returns the shortname
$path='C:\AreaSistemi1\'
foreach ($myFile in $myFiles)
get-childitem -path $myFile.Path *.spx | % {
" Starting File Process....." >> $myFile.Pathsistem.log
$PDate = get-date
$date = get-date -uformat "_%d_%m_%Y_%H%M%S.bak"
#"Set backup date to $date" >> $path\sistem.log
$newname=($_.fullname -replace ".spx",$date)
$file = [System.IO.Path]::GetFileNameWithoutExtension($_.fullname)
"File backup name is $newname" >> $myFile.Pathsistem.log
Rename-Item $_.fullname $newname
"Renamed file to $newname" >> $myFile.Pathsistem.log
$lines = get-content $newname
foreach ($line in $lines)
$line + " " + $myFile.ShortName | Out-File "$path\sistem.csv" -append
Write-Host $_.fullname
"Files Processed on $PDate are $newname " >> $path\sistem.log
Also looking at your script, you said your text file contained the format of <filePath>~<shortname> but I see you doing a $myFile.Pathisstem.log, where does the Pathisstem.log come from?
If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.
Don't Retire Technet -
How to read a excel file with more than one worksheet.
Hi,
I wanna read a sheet (anyone of it,not the first) in a excel.Who can help me!
best wishes,
Grant ChenDear All,
Thank you all for your reply!
I modified SAP FM ZALSM_EXCEL_TO_INTERNAL_TABLE.
I add an IMPORTING parameter 'I_SHEET'
which stands for the sequence number of worksheet in the FM.
FUNCTION ZALSM_EXCEL_TO_INTERNAL_TABLE .
*"*"Local Interface:
*" IMPORTING
*" VALUE(FILENAME) LIKE RLGRAP-FILENAME
*" REFERENCE(I_SHEET) TYPE I
*" VALUE(I_BEGIN_COL) TYPE I
*" VALUE(I_BEGIN_ROW) TYPE I
*" VALUE(I_END_COL) TYPE I
*" VALUE(I_END_ROW) TYPE I
*" TABLES
*" INTERN STRUCTURE ALSMEX_TABLINE
*" EXCEPTIONS
*" INCONSISTENT_PARAMETERS
*" UPLOAD_OLE
*{ INSERT EC6K900099 1
DATA: excel_tab TYPE ty_t_sender.
DATA: ld_separator TYPE c.
DATA: application TYPE ole2_object,
workbook TYPE ole2_object,
range TYPE ole2_object,
worksheet TYPE ole2_object.
DATA: h_cell TYPE ole2_object,
h_cell1 TYPE ole2_object.
DATA:
ld_rc TYPE i.
* Rückgabewert der Methode "clipboard_export "
* Makro für Fehlerbehandlung der Methods
DEFINE m_message.
case sy-subrc.
when 0.
when 1.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
when others. raise upload_ole.
endcase.
END-OF-DEFINITION.
* check parameters
IF i_begin_row > i_end_row. RAISE inconsistent_parameters. ENDIF.
IF i_begin_col > i_end_col. RAISE inconsistent_parameters. ENDIF.
* Get TAB-sign for separation of fields
CLASS cl_abap_char_utilities DEFINITION LOAD.
ld_separator = cl_abap_char_utilities=>horizontal_tab.
* open file in Excel
IF application-header = space OR application-handle = -1.
CREATE OBJECT application 'Excel.Application'.
m_message.
ENDIF.
CALL METHOD OF application 'Workbooks' = workbook.
m_message.
CALL METHOD OF workbook 'Open' EXPORTING #1 = filename.
m_message.
* set property of application 'Visible' = 1.
* m_message.
********************Modified by Grant 20080717************
call METHOD of application 'Worksheets' = worksheet
exporting
#1 = I_SHEET.
m_message.
call method of worksheet 'Activate'.
* GET PROPERTY OF application 'ACTIVESHEET' = worksheet.
m_message.
* mark whole spread sheet
CALL METHOD OF worksheet 'Cells' = h_cell
EXPORTING #1 = i_begin_row #2 = i_begin_col.
m_message.
CALL METHOD OF worksheet 'Cells' = h_cell1
EXPORTING #1 = i_end_row #2 = i_end_col.
m_message.
CALL METHOD OF worksheet 'RANGE' = range
EXPORTING #1 = h_cell #2 = h_cell1.
m_message.
CALL METHOD OF range 'SELECT'.
m_message.
* copy marked area (whole spread sheet) into Clippboard
CALL METHOD OF range 'COPY'.
m_message.
* read clipboard into ABAP
CALL METHOD cl_gui_frontend_services=>clipboard_import
IMPORTING
data = excel_tab
EXCEPTIONS
cntl_error = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE a037(alsmex).
ENDIF.
PERFORM separated_to_intern_convert TABLES excel_tab intern
USING ld_separator.
* clear clipboard
REFRESH excel_tab.
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
data = excel_tab
CHANGING
rc = ld_rc
EXCEPTIONS
cntl_error = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4
* quit Excel and free ABAP Object - unfortunately, this does not kill
* the Excel process
CALL METHOD OF application 'QUIT'.
m_message.
* >>>>> Begin of change note 575877
* to kill the Excel process it's necessary to free all used objects
FREE OBJECT h_cell. m_message.
FREE OBJECT h_cell1. m_message.
FREE OBJECT range. m_message.
FREE OBJECT worksheet. m_message.
FREE OBJECT workbook. m_message.
FREE OBJECT application. m_message.
* <<<<< End of change note 575877
*} INSERT
ENDFUNCTION.
Edited by: Grant Chen on Jul 17, 2008 7:45 AM
Edited by: Grant Chen on Jul 17, 2008 7:46 AM
Maybe you are looking for
-
I seem to have music files in various places on my laptop, on my husbands computer and our main imac. What we want to do is put all music on imac so when each of us logs on we have the same files availabe in itunes, but we logon seperately so we can
-
Hi Guru;s, My client has an requirement for automatic mail shooting to vendor with invoice number when payment is made through F110.Can somebody explain me how it can be achieved.Its a bit urgent. I know that it would be done through some event SAMPL
-
Outbound packing status is "Completed" before we pack in work centre
Hi, Once picking is completed (source and destination HU is same) immediately system says "packing completed" , in fact the next step is packing. Is it a right behavior in EWM? If i use outbound without storage process, how the packing status in ODO
-
How to delete apps permanently?
My friends thought it would be funny to download an app on sex advice, and I can't get rid of it. I've uninstalled it, but it's still in my app world! My dad goes on my PlayBook quite often and I don't want him seeing it! Is there any way that i can
-
Why is fast and furious 6 app not compatible with the ipod 4 gen
help