Reading two files at a time
Hi,
My sender system sends two files
1.Header
2.Item
I need to read both the files at a time.
If only both the files are present in the directory,i want pick the files otherwise not.
How can i do this validation in XI??
Thanks.
Rushikesh
Hi Rushikesh,
YOu can do this in two ways,
Either you use BPM or Shell script
BPM:
get the file in BPM and wait for second file,Furthur proess can be executed only if you get second file.
Shell script:
Write a script to get two files or conditions in script and exit
adapter wll call after your script.
Thanks
Prabhakar
Edited by: VenkataPrabhakar Teegavarapu on Oct 21, 2008 11:32 AM
Similar Messages
-
Dear All,
I will appreciate if somebody help me.
I want to read two files, one is temperature wich is updating every second, and the other is hysteresis energy which has specific rows and is constant.
I got a program in discussion forum which read a file as it is updating. I checked this program in my case and it works.
Then I added reading hysteresis energy file to the existing file. But while i am running the program, the hysteresis energy file is read with all rows.
But the aim is that everytime which temperature updates, I need to read just one row of the hysteresis energy file.
so, in this way in every second i have a new temperature data and one row of the other file.
I tried to used "for loop" inside the program, but it did not work, becuase reading temperature will be stopped untill for loop ends.
I attached the program.
Could somebody help me how to read just one row of hysteresis energy file everytime temperature updates?
Solved!
Go to Solution.
Attachments:
Readfiles.vi 23 KBI do not understand relationship between your two files.
You have another VI or app that is writing data to both files and when new temperature data added you wish just to read the new data and then read one new line of the hysteresis file?????
But is one is constant, why do you need to keep reading it?
Anyway…
The “Read From Spreadsheet File.vi” preformed an Open and a Close for each time it is called (if you will open the VI up and drill down and you will see). So that resets the file pointer back to the beginning and there for will read in the whole file from the first to the last each time if you do not set the start of read offset or number of rows.
Now the Read from Binary File does not reset the file pointer and leaves the file pointer just past the last byte read so it will start with any new bytes automaicly only giving you the new data.
I do not think you need to do the math with the Previous EOF=0 and the File size to get what I think you are trying to do.
Plus use shift reg for the Data string instead of local var
Set the mechinacl action of the stop botton to Latched
So you do not need to init the two controls
Also, I do not get the End of file encountered error (4) from the Read from Binary file if I attempt to read past. It just returns and empty string.
Omar
Attachments:
Readfiles.vi 22 KB -
Reading one file at a time using File Adapter
I am using a File Adapter which polls every minute to read files from a Folder. This process picks up all the files in that folder. What I want to achieve is that the File Adapter should read one file at a time. Is it possible to force it to wait for a few seconds before reading the Next file in the Folder. Or is there a solution to what I am trying to achieve? Any help would be appreciated.
public static char readChar() {
int ch;
char r = '\0';
boolean done = false;
while (!done) {
try {
ch = System.in.read();
r = (char) ch;
if (r == '\r') {
System.out.println("Not a character. Please try again!");
System.in.skip(1);
done = false;
} else {
System.in.skip(2);
done = true;
} catch (java.io.IOException e) {
done = true;
return r;
Try this as an method and then use it..
This code will read will be in response untill you hit the return key but will take only the first character.... -
Sender File adpater to Pick Two files at a time based on the file name
Hi Everyone,
I have a scenario where I need to pick two files at a time using file adapter where the two files names have a common string in between their names.For example , the file names can be sets like
H123.txt and L123.txt
H345.txt and L345.txt.
Now how do we handle this in the File Adapter ?Anu,
Two approaches.
1. Use BPM: use a collect pattern to pick those files: L and H files , use multi mapping to merge those files and map to IDoc. Constraint is that there must be a mandatory correlation field in both the files. Say a same po id in L and H file.
2. Use an Adapter module with additional files option in file Adapter. Operate on the Main payload and attachment inside your module code to get a combined contents of both files and proceed.
Module is preferable in terms of performance, but maintenance is difficult. Deployment after each changes, transport issues, etc.
BPM is resource intensive, but easy to maintain, transport.
Choose based on your requirement.
Regards,
Sudharshan N A -
How 2 read two files from 2 diff. directories, using single adapter
How 2 read two files from 2 diff. directories in same system, using single file adapter.
you can use advanced selection for source file
see
http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/frameset.htm -
Read two files and store it to Global Internal table in LSMW
Hi
I have a requirement in LSMW, there are two files which needs to read the data and upload into SAP based on 2nd file data with some conditions.
Example :
File One : Customer Details.
File Two : Customer Master.
when we upload the customer master data into SAP we have to cross check customer aganist file two(customer master).
If the customer is does not exist in the file two, then only we have create the customer other wise skip the record.
How to go about this, can we create any global internal table in LSMW and how to store the 2nd file data for cross check.
I tryed with define two source structures, but at any point of time 1st file data is only one record is available.
Please suggest some solutions.
Advance Thanks
Murali.Hi Jürgen L.
If customer is exist in the both files, then we need to extend him to other company codes.
Some reasons the data is not available in SAP, for writing select query. apart from this we have to do some validation based on 2nd file data.
Is there any possibility for global internal tables
Thanks
Murali -
Reading excel files in real time
Hello,
I would like to have a labVIEW program which permits to read several excel files, and collect all data in a single excel file.
I know that it is possible to write a program which can read multiple files.
But I would like to know that if its possible to read files in a real time:
for ex. each time there is a new excel file to read, the LabVIEW program read it automatically and add its data to the final file?
Thank you and bests regardsAs Sam notes, it is certainly possible to merge Excel Files (I've done it, myself). An oft-repeated Best Practice for Program Development, which I didn't understand nor start following until quite recently, is "Write the Documentation First". In this case, you want to think carefully (and specify in a Document, which tends to "clarify your thinking") a number of issues:
Where will you look for the Excel Files to be merged? [Hint -- it's much easier if they are all in the same Folder).
Where will you save the Merged File? Will it be in the same Folder as the Source Files?
How will the Merged File be named? This can have an interaction effect with the previous points.
What is the structure of the Source, and of the Merged, File? Is it "obvious" how the Merge is to take place?
Related to #4, are there Headers? Multiple WorkSheets?
How do you know when it is time to Merge? Are you checking for new files periodically? How often?
In some ways, these "structure" questions are trickier to design and thornier to deal with than simply reading data from two Excel Files and writing the data to a third (which I'm calling a Merge). Note that I'm assuming that you are really dealing with Excel files (.xls, .xlsx), for which I recommend using the Report Generation Toolkit. If you are speaking about Comma-Separated Variable (.csv) files that LabVIEW calls "Spreadsheets", the above questions are still mostly relevant, but your approach will be a little different.
Write yourself a Document, show it to us, and if you have ideas on how to do this, give it a try and show us your code -- we'll try to provide assistance if you "get stuck".
Bob Schor -
Append two files with added time stamp
Hi experts,'
MY Requirement is I need to pick two files from two different FTP Locations and append them to file receiver FTP Location with Added timestamp.
How to achive this as with append we do not get option of adding time stamp.
Other thing is I want all the appended files should be there in Receiver folder means like if we get two files today they should be appended to one and shld be put in Receiver folder then two files for tomorrow and they shoud be appended as a separate file in Receiver Folder.
How to achive this??
Regards,
NidhiHi Nidhi,
>>MY Requirement is I need to pick two files from two different FTP Locations and append them to file receiver FTP Location with Added timestamp
Use BPM and pick the two files
>>Other thing is I want all the appended files should be there in Receiver folder means like if we get two files today they should be appended to one and shld be put in Receiver folder then two files for tomorrow and they should be appended as a separate file in Receiver Folder.
Use variable substitution and create the directory and filename dynamically...
Use Dynamic configuration module in receiver adapter and do as specified in this blog:
/people/madanmohan.agrawal/blog/2009/05/20/combining-three-different-aspects-of-pi-asma-af-module-and-variable-substitution-in-one-shot
Regards
Suraj -
I want to be able to read just few files at a time in a given directory. File Class provides .list() but it gets all the files or if I use FileNameFilter then based on file name - still it will try to read all the file names. But what I want is to read few files. We have 3 million files in a directory, how can I read 100 or say 1000 files at a time. File.list() is going to try to load all the file names at once.
How to do that without reading the entiredirectory?
JVM doesn't have to load the entire list to do this.
It could be implemented using native OS calls. I
don't know if they exist or not or if JVM has
bindings to them, etc. But I was hoping there was
something there. I guess not."...getting a list of files that match some search criteria?" (as you said) requires something (Java or an underlying native OS) to acquire the entire directory listing and then select from the listing, in some manner. And this is what the OP didn't want to do. -
Why does my quicktime player version 10.2 sometimes read AVI video and other times it will not recognize that same file. I have a video card that sometimes it will read then the next time it recognizes the card but will not open the video. Message says "quicktime does not recognize this file.
Whats up with that ??? Any help will be most appreciated!AVI is a container just like MKV, WMV, MOV, and MPEG. It is possible to use many different compression formats aka. codecs in an AVI container.
Think of the container - AVI as being an envelope, and the compressed video in it as a letter. The letter may be in a language you cannot read even though you know how to open the envelope.
Historically QuickTime did have some built-in ability to use AVI files and some formats in those files, this used to be further improved by installing the free Perian (for Mac only). However with Mavericks Apple have removed the ability for QuickTime X aka. QuickTime Player 10 to use AVI files, it now really only accepts MPEG4 or H.264.
It is still possible to install QuickTime 7.6.6 in Mavericks and if you use it and Perian rather than QuickTime X you can still use various AVI files.
Note: Mavericks also now no longer shows previews or thumbnails for AVI files for the same reason. -
Read txt file 1 char @ time cnvrt to uppercase problem
I am trying to get the following 2 problems solved. My input file is below and my output is below along with the code.
Can anyone fix this and explain what I am doing wrong? Thank You in advance!
(1) Any string of two or more blanks symbols is replaced by a single blanks.
(2) All sentences start with an upper case letter.
Input A://DataIn.txt = How me? you good.
Output A://DataOut.txt = H o w m e Y U G O . ��
import java.io.*;
public class NumberFormat
private DataInputStream inputStream = null;
private DataOutputStream outputStream = null;
*(1) Any string of two or more blanks symbols is replaced by a single blanks.
(2) All sentences start with an upper case letter.
public static void main(String[] args) throws java.io.IOException
NumberFormat twoTimer = new NumberFormat();
twoTimer.connectToInputFile();
twoTimer.connectToOutputFile();
twoTimer.readInput();
twoTimer.closeFiles();
System.out.println("Check A:/DataOut.txt Now");
public void connectToInputFile()
String inputFileName = getFileName("Enter input file name: A://DataIn.txt");
try
inputStream =
new DataInputStream(
new FileInputStream(inputFileName));
catch(FileNotFoundException e)
System.out.println("File " + inputFileName
+ " not found.");
System.exit(0);
public void connectToOutputFile()
String outputFileName = getFileName("Enter output file name: A://DataOut.txt");
try
outputStream = new DataOutputStream(
new FileOutputStream(outputFileName));
catch(FileNotFoundException e)
System.out.println("Error opening output file "
+ outputFileName);
System.out.println(e.getMessage());
System.exit(0);
private String getFileName(String prompt)
String fileName = null;
System.out.println(prompt);
fileName = SavitchIn.readLineWord();
return fileName;
//===========================================================================
public void readInput()
char prevChar = ' ';
try
char nextChar;
String result = "";
boolean done1 = false;
boolean done2 = false;
char next;
do
next = (char) (inputStream.read()); // <== Read input 1 Character @ time
if (next == '\n')
done1 = true;
if (next == ' ' && next == prevChar)
prevChar = next;
else
if (next == '.' || next == '!' || next == '?')// <== Capitalize next input Character
do
next = ' ';
outputStream.writeChar(next);
next = (char) (inputStream.read());
if (next == '\n')
done2 = true;
next = (char) (inputStream.read());
// next = (char) (inputStream.readNonwhiteChar()); ?????????????
if (next == '\n')// <== never gets to end of file
done2 = true;
outputStream.writeChar(Character.toUpperCase (next));
prevChar = next;
while (!done2);
else
outputStream.writeChar(next);
prevChar = next;
while (!done1);
catch(EOFException e)
//Do nothing. This just ends the loop.
System.out.println("Do Nothing Here");
catch(IOException e)
System.out.println(
"Error: reading or writing files.");
System.out.println(e.getMessage());
System.exit(0);
public void closeFiles()
try
inputStream.close();
outputStream.close();
catch(IOException e)
System.out.println("Error closing files "
+ e.getMessage());
System.exit(0);This line looks fishy:
if (next == ' ' && next == prevChar)
prevChar = next;Try:
if (next == ' ' && next == prevChar)
next = "";That should take care of the extra blanks, though I didn't test it myself, and could very well be wrong.
Not sure about the uppercase, though I imagine it must be reading the ToUpperCase every time after the first period. -
Reading log file and calculating time between
If someone could help me with this one, I would be very grateful.
I have a log file and I need to search a string that contains a start time and end time (eg. <time="11:10:58.000+000">). When I have these two values, I need to measure the time that has been elapsed between these two (from start to end).$Path="C:\Times.log"
remove-item $Path
Add-Content $Path '<time="11:10:58.000+000">'
Add-Content $Path '<time="12:10:58.000+000">'
Add-Content $Path '<time="13:10:58.000+000">'
Add-Content $Path '<time="15:13:38.000+000">'
Add-Content $Path '<time="16:10:58.000+000">'
Add-Content $Path '<time="17:08:28.000+000">'
$File=Get-Content $Path
$StartTime=$Null
$EndTime=$Null
$ElapsedTime = $Null
ForEach ($Line in $File)
If ($Line.Contains("time="))
$Position = $Line.IndexOf("time=")
$TimeStr =$Line.SubString($Position+6,8)
IF ($StartTime -EQ $Null)
$StartTime = $TimeStr -As [System.TimeSpan]
Else
$EndTime = $TimeStr -As [System.TimeSpan]
$ElapsedTime = $EndTime.Subtract($StartTime)
"StartTime=$StartTime EndTime=$EndTime ElapsedTime=$ElapsedTime"
$StartTime = $Null
Gives this output
StartTime=11:10:58 EndTime=12:10:58 ElapsedTime=01:00:00
StartTime=13:10:58 EndTime=15:13:38 ElapsedTime=02:02:40
StartTime=16:10:58 EndTime=17:08:28 ElapsedTime=00:57:30 -
CSV file reading using UTL_FILE at run time
Hi,
I have to read CSV file using UTL_FILE.
but Folder contains Many CSV files.
I dont know there name.So i have to read csv file at run time.
Please let me know how should we achieve this?
Thanksplace the following in a shell script, say "list_my_files.ksh"
ls -l > my_file_list.datthen run the shell script using dbms_scheduler;
begin
dbms_scheduler.create_program (program_name => 'a_test_proc'
,program_type => 'EXECUTABLE'
,program_action => '/home/bluefrog/list_my_files.ksh'
,number_of_arguments => 0
,enabled => true);
end;
/then open "my_file_list.dat" using UTL_FILE, read all file names and choose the one you require.
P; -
Reading two data points at a time in Excel
I would like some help on a programming issue:
I know how to read whole excel data sets but how do you read two points at a time? I would like to extract a number from row 1 column 1 and row 1 column 2. I will use these numbers simultaneously as for loop counters. Then the program should read row 2 column 1 and row 2 column 2. This pattern should continue (number of times unknown) until the two numbers both equal 0.
Please help me with any suggestions you have.
Thanks ahead of time!Hi mtcellar65
1. you know how to read the whole excel data - just read the 2D Array (whole information)
2. extract the single elements using 'Index Array' Function.
the index for row and column can be kept in a shift register.
3. increment the indices and repeat step 2 again
hope this helps
Renn
Kudos always welcome for helpful posts -
File Adapter - Reading 2 files from sender and one file to receiver
All - I am looking for a best solution for reading two files from sender and generating one file to the receiver.
Here is the scenario
Sender file s - A is a master file. B is a detail file; B will have a one to many records for each record of File A.. that is the relation ship between 2 files.. I am looking for a better solution to
Example
Input:
File A will have a record like "summary1 ABC 1234"
File B will have a record like "Detailfor Summary1 CDF 8679"
Output:
File C shall have a record "consolidatedofSummary&Detail ABC 1234 8679"
1) read records of master row and detail row from these 2 files
2) do the mapping to the receiver output format which it is creating for records with some harcoded values and based on the values from master and detail rows of sender file
if I can accomblish reading sender files and do the mapping to the receiver , assume that mapping to the receiver format would not be cumbersome.
please help me...
ThanksHi Gopal,
Ur approach to the interface is perfect.... Go ahead.
For selecting multiple files in source use Advanced Selection for files.. and specify the directory paths and also the file name shema...
This will fetch the 2 files into the integration engine... then u map the 2 source files to one target file(2:1 mapping).
Specify accordingly the receiver side FCC and test it end to end...
If u face any prblm post here... some1 will help u out..
Babu
Maybe you are looking for
-
Hi, I have just cancelled my BT Vision service (OH does not like it) but still have BT Broadband and Calls which we are not changing. We have no phone line downstairs but a phone line upstairs and are using the BT powerline adapters. The powerline
-
Hi, I uploaded some flv videos to my blog and can see it fine on my G5, my the videos will not play in Safari on my iPhone iOS4. Anyone know how to fix this?
-
Question about making pdfs from Illustrator files
Hi, can someone tell me how to solve the following problem? I am preparing pdfs that will be loaded onto a website. At the moment, I make pdfs of each Illustrator file (corresponding to each page of the document). Our current IT guy then processes th
-
QM inspection for movement 321 and 322
Dear guru, Presently there is one new requirement from our business wanting us to create an inspection type that will allow for users to use movement type 321 & 322 through MIGO. Because the standard SAP setup (i.e. SPRO QM Quality Inspection I
-
How do I convert a DVD to a format suitable for a Digital Download?
I need guidance as to the best way to convert a DVD to a format suitable for a digital download. I am a web developer not a video expert, I only have access to Premiere Pro as a Creative Cloud subscriber. I'm not even sure if this is the best applica