Appending to a file
Can someone please let me know the reason(s) why appending data to an existing file only works with TEXT file and It does not work for MS word decoment or MS Excel file ?
Is there another way ( Methods ) to append to these type of files than RandomAccessFile or ByteBuffer methods
Thanks in advance
IB
For example, maybe the Word format looks like this:
First 256 bytes: a directory listing
Bytes 257 to N (as defined by directory): textual data
Bytes N to M (again defined by directory): local dictionaries or other support data
Bytes M to end: undo information, in a stack structure.
And each of those subsections have their own format with their own intricacies.
If that were the format, adding more data to the end wouldn't do anything other than corrupt the file.
I don't know if it's the actual format...I'm sure it's not...but I'll bet there are some similarities and it's closer to that than to a plain text file.
Similar Messages
-
How to append two CSV files using ftp
Hi
Please let me know the FTP command to append the two .CSV files into one .CSV file.
e.g.
Let me explain:
one CSV file has the fields F1 , F2, F3 , F4 and has 5 records
another CSV file has the same sequence of fields F1, F2, F3, F4 and has 10 records
after appending both the files , I must get 15 records.
Thanks
AlokOk I will try out.
I am illustrating my requirement as follow
File#1 (type .CSV)
F1 F2 F3 F4
100 566 89 86
235 256 56 12
File#2 (type .CSV)
F1 F2 F3 F4
56 56 98 102
12 23 36 523
23 56 56 89
Now we want to Append File#1 to File#2 as follow:
F1 F2 F3 F4
100 566 89 86
235 256 56 12
56 56 98 102
12 23 36 523
23 56 56 89
Please suggest now that which command would be appropiate.
Alok -
Problem with Append mode in File Receiver
Hello,
I am facing some problem with Append Mode in File Receiver.
In channel config, i have given :
Construction Mode : Append
File Type : Text
Message Protocol : File Content Conversion
The size of the file which i am trying to send is about 9.5MB.
I got this error,
"Recovering from loss of connection to database; message
loaded into queue by recover job: System Job (Failover Recovery)".
So, it would seem that there was a loss of connnection to the database
while the file was being written.
Note - XI successfully recovered from the connection loss and
successfully wrote the file, however since the communication channel
was set to append, it appended to the partial file that was written
before the database connection loss. This is not correct. The file
should have been overwritten after the recovery even though the communication
channel was configured to append.
Can anyone help me on this regard.
Thanks,
Soorya.Hi Venkat,
I would suggest u to split the file in to chunks if u face any problem in processing at a time in append mode and also
Memory Requirements are must 4 processing huge files:
Q: Which memory requirements does the File Adapter have? Is there a restriction on the maximum file size it can process?
A: The maximum file size that can be processed by the File Adapter depends on a number of factors:
o The most important one is the size of the Java heap, which is shared among all messages processed at a certain point in time. In order to be able to process larger messages without an out of memory error (OOM), it is recommended to increase the size of the available Java heap and/or to reduce the concurrency in the system so that fewer messages are processed in parallel.
o Another factor negatively influencing the maximum message size in releases up to and including XI 3.0 SP 13 is an enabled charcter set (encoding) conversion if the message type is set to "Text".
o Using the transport protocol "File Transfer Protocol (FTP)" also uses more memory for processing than the transport protocol "File System (NFS)" (up to and including XI 3.0 SP 13).
o If the Message Protocol "File Content Conversion" is used in a File Sender channel, consider that not only the size of the input file affects the File Adapter's memory usage, but even more the size of the XML resulting from the conversion, which is usually a few factors larger than the original plain text file.
To reduce the memory consumption in this scenario, consider configuring the setting "Maximum Recordsets per Message" for the sender channel. This will cause the input file to be split into multiple smaller mesages.
Plz do refer the following links:
U may plan the availability of ur communication channel using "Planning Availability Times" feature
http://help.sap.com/saphelp_nw04/helpdata/en/45/06bd029da31122e10000000a11466f/frameset.htm
/people/sravya.talanki2/blog/2005/11/29/night-mare-processing-huge-files-in-sap-xi
hi check the below links for reference
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10748ef7-b2f0-2910-7cb8-c81e7f284af5
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/7086f109-aaa7-2a10-0cb5-f69bd2affd2b
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2498bf90-0201-0010-4884-83568752a857
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cc1ec146-0a01-0010-90a9-b1df1d2f346f
Regards,
Vinod. -
External Table which can handle appending multiple csv files dynamic
I need an external table which can handle appending multiple csv files' values.
But the problem I am having is : the number of csv files are not fixed.
I can have between 2 to 6-7 files with the suffix as current_date. Lets say it will be like my_file1_aug_08_1.csv, my_file1_aug_08_2.csv, my_file1_aug_08_3.csv etc. and so on.
I can do it by following as hardcoding if I know the number of files, but unfortunately the number is not fixed and need to something dynamically to inject with a wildcard search of file pattern.
CREATE TABLE my_et_tbl
my_field1 varchar2(4000),
my_field2 varchar2(4000)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY my_et_dir
ACCESS PARAMETERS
( RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ','
MISSING FIELD VALUES ARE NULL )
LOCATION (UTL_DIR:'my_file2_5_aug_08.csv','my_file2_5_aug_08.csv')
REJECT LIMIT UNLIMITED
NOPARALLEL
NOMONITORING;Please advice me with your ideas. thanks.
Joshua..Well, you could do it dynamically by constructing location value:
SQL> CREATE TABLE emp_load
2 (
3 employee_number CHAR(5),
4 employee_dob CHAR(20),
5 employee_last_name CHAR(20),
6 employee_first_name CHAR(15),
7 employee_middle_name CHAR(15),
8 employee_hire_date DATE
9 )
10 ORGANIZATION EXTERNAL
11 (
12 TYPE ORACLE_LOADER
13 DEFAULT DIRECTORY tmp
14 ACCESS PARAMETERS
15 (
16 RECORDS DELIMITED BY NEWLINE
17 FIELDS (
18 employee_number CHAR(2),
19 employee_dob CHAR(20),
20 employee_last_name CHAR(18),
21 employee_first_name CHAR(11),
22 employee_middle_name CHAR(11),
23 employee_hire_date CHAR(10) date_format DATE mask "mm/dd/yyyy"
24 )
25 )
26 LOCATION ('info*.dat')
27 )
28 /
Table created.
SQL> select * from emp_load;
select * from emp_load
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
SQL> set serveroutput on
SQL> declare
2 v_exists boolean;
3 v_file_length number;
4 v_blocksize number;
5 v_stmt varchar2(1000) := 'alter table emp_load location(';
6 i number := 1;
7 begin
8 loop
9 utl_file.fgetattr(
10 'TMP',
11 'info' || i || '.dat',
12 v_exists,
13 v_file_length,
14 v_blocksize
15 );
16 exit when not v_exists;
17 v_stmt := v_stmt || '''info' || i || '.dat'',';
18 i := i + 1;
19 end loop;
20 v_stmt := rtrim(v_stmt,',') || ')';
21 dbms_output.put_line(v_stmt);
22 execute immediate v_stmt;
23 end;
24 /
alter table emp_load location('info1.dat','info2.dat')
PL/SQL procedure successfully completed.
SQL> select * from emp_load;
EMPLO EMPLOYEE_DOB EMPLOYEE_LAST_NAME EMPLOYEE_FIRST_ EMPLOYEE_MIDDLE
EMPLOYEE_
56 november, 15, 1980 baker mary alice 0
01-SEP-04
87 december, 20, 1970 roper lisa marie 0
01-JAN-99
SQL> SY.
P.S. Keep in mind that changing location will affect all sessions referencing external table. -
Appending multiple *.csv files while retaining the original file name in the first column
Hi guys it's been awhile.
I'm trying to append multiple *.csv files while retaining the original file name in the first column, the actual data set is about 40 files.
file a.csv contains:
1, line one in a.csv
2, line two in a.csv
file b.csv contains:
1, line one in b.csv
2, line two in b.csv
output.csv result is this:
I would like this:
a.csv, 1, line one in a.csv
a.csv, 2, line two in a.csv
b.csv, 1, line one in b.csv
b.csv, 2, line two in b.csv
Any suggestions to speed up my hobbling attempts would be aprieciated
Thanks,
-SS
Solved!
Go to Solution.What you could do is given in the attachment.
Started with 2 files :
a.csv
copy of a.csv
Both with data :
1;1.123
2;2.234
3;3.345
Output :
a.csv;1;1.123
a.csv;2;2.234
a.csv;3;3.345
Copy of a.csv;1;1.123
Copy of a.csv;2;2.234
Copy of a.csv;3;3.345
If you have more questions, just shoot
Kind regards,
- Bjorn -
Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's
LabVIEW 5.1 - LabVIEW 2012
Attachments:
AppendingCSV.JPG 73 KB -
How to read appended objects from file with ObjectInputStream?
Hi to everyone. I'm new to Java so my question may look really stupid to most of you but I couldn't fined a solution by myself... I wanted to make an application, something like address book that is storing information about different people. So I decided to make a class that will hold the information for each person (for example: nickname, name, e-mail, web address and so on), then using the ObjectOutputStream the information will be save to a file. If I want to add a new record for a new person I'll simply append it to the already existing file. So far so good but soon I discovered that I can not read the appended objects using ObjectInputStream.
What I mean is that if I create new file and then in one session save several objects to it using ObjectOutputStream they all will be read with no problem by ObjectInputStream. But after that if in a new session I append new objects they won't be read. The ObjectInputStream will read the objects from the first session after that IOException will be generated and the reading will stop just before the appended objects from the second session.
The following is just a simple test it's not actual code from the program I was talking about. Instead of objects containing different kind of information I'm using only strings here. To use the program use as arguments in the console "w" to create new file followed by the file name and the strings you want save to the file (as objects). Example: "+w TestFile.obj Thats Just A Test+". Then to read it use "r" (for reading), followed by the file name. Example "+r TestFile.obj+". As a result you'll see that all the strings that are saved in the file can be successfully read back. Then do the same: "+w TestFile.obj Thats Second Test+" and then read again "+r TestFile.obj+". What will happen is that the strings only from the first sessions will be read and the ones from the second session will not.
I am sorry for making this that long but I couldn't explain it more simple. If someone can give me a solution I'll be happy to hear it! ^.^ I'll also be glad if someone propose different approach of the problem! Here is the code:
import java.io.*;
class Fio
public static void main(String[] args)
try
if (args[0].equals("w"))
FileOutputStream fos = new FileOutputStream(args[1], true);
ObjectOutputStream oos = new ObjectOutputStream(fos);
for (int i = 2; i < args.length ; i++)
oos.writeObject(args);
fos.close();
else if (args[0].equals("r"))
FileInputStream fis = new FileInputStream(args[1]);
ObjectInputStream ois = new ObjectInputStream(fis);
for (int i = 0; i < fis.available(); i++)
System.out.println((String)ois.readObject());
fis.close();
else
System.out.println("Wrong args!");
catch (IndexOutOfBoundsException exc)
System.out.println("You must use \"w\" or \"r\" followed by the file name as args!");
catch (IOException exc)
System.out.println("I/O exception appeard!");
catch (ClassNotFoundException exc)
System.out.println("Can not find the needed class");How to read appended objects from file with ObjectInputStream? The short answer is you can't.
The long answer is you can if you put some work into it. The general outline would be to create a file with a format that will allow the storage of multiple streams within it. If you use a RandomAccessFile, you can create a header containing the length. If you use streams, you'll have to use a block protocol. The reason for this is that I don't think ObjectInputStream is guaranteed to read the same number of bytes ObjectOutputStream writes to it (e.g., it could skip ending padding or such).
Next, you'll need to create an object that can return more InputStream objects, one per stream written to the file.
Not trivial, but that's how you'd do it. -
Appending a .sql file to a pdf
Is it possible to append a .sql file to a PDF as an Appendix. I am using Acrobat Pro 9.
Hi randha m,
What actually you mean by append. Do you mean attach. Try to elaborate little more your query.
Regards,
Ajlan Huda. -
Hello everyone
I am working on a galil motor controller for a stepper motor. I have a fully functioning code for the stepper motor but I am now trying to create a data file to log the motors activity. I have created two attempts at appending to a file everytime the motor changes position. One of my attempts was a shift register using a while loop, it works the only problem with it is that it is constantly running. This makes the motor run constantly so if I set an angle itll try to keep setting it as long as the while loop is running.
Attached is my VI I have worked very hard at this. Please let me know how i could fix it
Thanks
Attachments:
galil mc USER rotationTESTING 5-13.vi 251 KB
galil mc USER rotation 5-12-14.vi 237 KBYou write to the file before setting the pointer to the end. Here, I made a very simple edit that should get you going.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Attachments:
Append to File.PNG 50 KB -
Append an existing file?
Hello world,
I'm stuck in a predicament: The storage guys have asked me to reduce the frequency of backups on three of our instances to save bandwidth on the WAN when the backup files are copied across to another datacenter. The application owners do not want to backup
any less frequently.
We do daily full backups and Tr-log backups every 15 minutes throughout the day.
Storage have advised that the SAN only copies changes (ie new files or the changes to existing ones)
Is it possible/ would it be of any benefit, to backup and append an existing file? Can I do this with the logs as with the databases?
Thanks in advanceStorage have advised that the SAN only copies changes (ie new files or the changes to existing ones)
I am not very sure that it will pick changes from existing ones, I think if it sees the file is changed it will start coping as 1 big file and will not solve your purpose. You might get it reconfirm with storage on this. Also even if it does like you said
I wonder if next backup runs and file is still getting copied over then backup will start failing saying "file is in use".
If application owner is saying 15 min log backup then we cant reduce the frequency, but if you have some other drive/disk where you can divert tlog backup say for 2 hours then you can run differential backup every 2 hour which goes to SAN. You will be safe
even if something happen you have tlog on 1 drive and
differential get copied to other datacenter. (But point in time recovery will be issue as you will not have any tlog backups for restore)
I cant think of anything else to reduce frequency, but for bandwidth see if you can use compress(enterprise edition) or zip backup file to save bandwidth. -
Append text in file. and save it
Append text in file.
hi!
i am new j2me Programer.
1.i want to add(APPEND) the text in the file. i take this code form internet but i could succed Please help me.
2.i want to save it in other directory like if i made folder on mobile device with name c:\Old i want to save file in that how could i ?
kindly mention the Mistake.
package FileConnection;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;
* @author QTracker
public class FileConnection extends MIDlet implements CommandListener {
private boolean midletPaused = false;
private Command exit, start;
private Display display;
private Form form;
public FileConnection ()
display = Display.getDisplay(this);
exit = new Command("Exit", Command.EXIT, 1);
start = new Command("Start", Command.EXIT, 1);
form = new Form("Write To File");
form.addCommand(exit);
form.addCommand(start);
form.setCommandListener(this);
private void initialize() { }
public void startMIDlet() { }
public void resumeMIDlet() {/
public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
Display display = getDisplay();
if (alert == null) {
display.setCurrent(nextDisplayable);
} else {
display.setCurrent(alert, nextDisplayable);
public Display getDisplay () {
return Display.getDisplay(this);
public void exitMIDlet() {
switchDisplayable (null, null);
destroyApp(true);
notifyDestroyed();
public void startApp() {
display.setCurrent(form);
public void pauseApp() {
midletPaused = true;
public void destroyApp(boolean unconditional) {
public void commandAction(Command c, Displayable d) {
if (c == exit)
destroyApp(false);
notifyDestroyed();
else if (c == start)
try
OutputConnection connection = (OutputConnection)
Connector.open("file:\\c:\\myfile.txt;append=true", Connector.WRITE );
OutputStream out = connection.openOutputStream();
PrintStream output = new PrintStream( out );
output.println( "This is a test." );
out.close();
connection.close();
Alert alert = new Alert("Completed", "Data Written", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
catch( ConnectionNotFoundException error )
Alert alert = new Alert(
"Error", "Cannot access file.", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
catch( IOException error )
Alert alert = new Alert("Error", error.toString(), null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}| Moderator advice: | Please read the announcement(s) at the top of the forum listings and the FAQ linked from every page. They are there for a purpose. |
| | Please don't post in threads that are long dead and don't hijack another poster's thread. |
| | Please don't solicit off forum communication by email. |
| Moderator action: | The other four posts you made have been deleted. |
db -
How do I append a txt file? When I re-open, I cant append to the file.
Trying to append a txt file but cant because of the header.
How do i print to the file without the header?
The Add Record Class
private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {
int lengthIsbn = txtIsbn.getText().length(); //get lengths for validation
int lengthSupplierno = txtSupplierno.getText().length();
int lengthLastorderdate = txtLastorderdate.getText().length();
if (lengthIsbn == 11){
if (lengthSupplierno == 4){ //check validation
if (lengthLastorderdate == 8){ //Three If's because one can only have one error which cannot be specific!
// if passed validation then continue the add
bookRecord record;
try{
record = new bookRecord(
txtIsbn.getText(),
txtTitle.getText(),
txtAuthor.getText(),
Float.parseFloat(txtPrice.getText()),
Integer.parseInt(txtSupplierno.getText()),
txtLastorderdate.getText());
Output.writeObject(record);
System.out.println(record); // print record to check progress
} catch(IOException b){
JOptionPane.showMessageDialog(this, "Cannot Add Record Due To Input/Output Error!", "IO Error", JOptionPane.ERROR_MESSAGE);
} catch(NumberFormatException d){
JOptionPane.showMessageDialog(this, "Cannot Add Record Due To Incorrect Formatting Of Data In Text Boxes, Please Check That Price And Supplier No Are Numeric!", "Number Format Error", JOptionPane.ERROR_MESSAGE);
} catch(NullPointerException e){
JOptionPane.showMessageDialog(this, "Cannot add Record Due To Absence Of Database!", "Null Pointer Error", JOptionPane.ERROR_MESSAGE);
} else {JOptionPane.showMessageDialog(this, "Last Order Date Must Be In This Format (01/01/01)", "Validation Error", JOptionPane.ERROR_MESSAGE);}
} else {JOptionPane.showMessageDialog(this, "Supplier No Must Be A Four Digit Integer", "Validation Error", JOptionPane.ERROR_MESSAGE);}
} else {JOptionPane.showMessageDialog(this, "ISBN Must Have 11 Characters", "Validation Error", JOptionPane.ERROR_MESSAGE);}
} I dont know whats wrong...1) You append to a file by passing true for the append argument to the constructor for the FileOutputStream or FileWriter.
2) I have no idea what you mean by this: Trying to append a txt file but cant because of the header. How do i print to the file without the header?
3) You're saying it's a txt file, but you're calling Output.writeObject(record). If Output is an ObjectOutputStream, (that is, you're serializing record) then it's not a text file.
4) Variable names conventionally start with lowercase in Java, so Output should be output. (Unless Output is a class name and writeObject is a static method.) -
Appending multiple xml files to single xml file using File channel?
Hi Experts,
I would like to get some pointers around xml files append.
My sender application will send around 1000 messages through SOAP per day. But the target application needs single xml file formed by consolidation of all these 1000 files.
I tried with txt files and the receiver file channel could append the txt files. However, since xml files allow only one root node, I am not able to achieve the requirement.
Is there any option we can do to get the result?
The target file location is UNIX folder. Do we need to create any shell script to run from the channel for appending the file?
Do we need to use any XSLT mapping to strip the xml declaration tags and append the files. Once the single file is ready, using another file channel with XSLT mapping, insert a dummy root node and xml declaration tags to build an xml file?
Any thoughts to get the result will be much appreciated.
Thanks
Ray..Hi,
You have two options
1)Using Receiver Sender File channel select mode append it does the job.
Option 2:
Using BPM we cann collect all messages per day and club them as a one message, in this case create Target data type root node occurance 1 to unbounded. so it cal hold multiples SOAP messages in only XML messages.
search in sdn for BPM collect pattrersn,its very simple .
Option 3:
Create scheell script in OS level and write a logic to append all files planced in FTP.
Regards,
Raj -
Hi,
I have a VI that controls a stepper motor attached to a camera. I want people to be able to access this camera and control its position through the web. Is there any way to append an HTML file or icon from labview and rotate the camera with the data sent from the web?
Thank you for your help.
Guillermo Naranjo
Solved!
Go to Solution.I tried using the labview web publishing tool like you suggested, but when I tried to preview the page (even with the VI running) I only get the border of the front panel without the VI in it. Do you know why this is happening?
Thank you for your help.
Guillermo Naranjo
Attachments:
frontpanel.jpg 29 KB -
Hi everyone,
I have created a zip file (test.zip), but i cant figure out how to append a text file to it.
Can anybody help?http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/ZipInputStream.html#createZipEntry(java.lang.String)
-
I need to append to mp3 files into a single mp3 file.
let us say we have 1.mp3 and 2.mp3 then we need to append 1 and 2 into 3.mp3 so that the third mp3 file will play the first and then the second mp3 file.
but the sound api by sun does not support the mp3 file format so
AudioInputStream audioInputStream1= AudioSystem.getAudioInputStream(fileIn);
is throwing an unsupported format exception.
but for wav files its working perfect by using the SequenceInputStream.
I need the same for the mp3 files also .Check out the tritonus mp3 plug-in.
http://tritonus.org/plugins.html
I believe that with it you can decode the mp3's and
append them as wav files. Then just encode the audio
back to mp3.
kari-matti
Maybe you are looking for
-
I am able to locate Bright Flashlight. I click on download and it takes me to a page with several items to put in a shopping cart but no downloads. The initial link shows it as a free download. Is there any way to download this from my computer and s
-
Can I have an iPhone, ipad and MacBook Pro with the same apple id
Can I have an iPhone, ipad and MacBook Pro with the same apple id. When I use I tunes it get confusing and I have a paid app that needs the same id
-
The sound on my iPhone isn't working I don't understand why it was working fine an hour ago I haven't dropped it or anything simply just out it on silent... The music I was trying to listen to didn't want to make a sound when I turned it in , I put a
-
Movie chapter thumbnails gone after 4.2 update
Hello fellow iPad users. I've looked around the internet for this and haven't found anything about this. I had three movies on my iPad when I updated to 4.2. I went to play one after I updated and noticed that the chapter thumbnails are now gone. The
-
List of all persons in OrgStruct with Managers?
Hello Everyone, I want to get a table of all the people in a particular org (including all orgs rolling up to it) with the following: person's pernr manager's pernr org # and a few other details (not as important) I'm having a hard time putting this