473,322 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

file copying data from .txt to .dat

11
Hi I need to copy the first 3 lines of a "example.txt" file to a "sample.dat" file, how do I do it? i tried getline but that duz'nt give me the entire header of the file. the first three lines of the file are:

P6
# Created by IrfanView
550 300
255

I can use getline(str,80,'\n') , but then how to regresh str, to use getline 2 more times for the next 2 lines.
Please help
Sep 11 '06 #1
1 3230
Banfa
9,065 Expert Mod 8TB
I have no idea what "how to regresh str" means.

However the problem you have is easy to solve, open the input and the output file at the same time, as you read each line in turn write it to the output file. This will allow you to reuse the same buffer for each line read, you wont have to store anything.
Sep 12 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Luc Saffre | last post by:
Hello, I had a strange problem when freezing (using either py2exe or McMillan installer) a script that imports reportlab (which imports PIL (which imports FixTk))). - Python 2.3.3c (also with...
5
by: Thomas Lotze | last post by:
Hi, another question: What's the most efficient way of copying data between two file-like objects? f1.write(f2.read()) doesn't seem to me as efficient as it might be, as a string containing...
4
by: Fredrik Henricsson | last post by:
Hey, I'm building an ontology in Protégé and I want to transform parts of it (e.g. the instances) to HTML with XSL. When I was transforming another file with 'simple' XML-tags like <author> before,...
2
by: Mike MacSween | last post by:
I'm not talking Access Users & Groups, I may or may not implement that. Even if I do file/folder rights still need to be managed. I've searched the archives and read the many postings. The basic...
2
by: Ryan Riddell | last post by:
I wrote an application to pull data from certain ranges of an Excel workbook. The application works great for the first 2 of 4 sections I created. I created the third section of code and the...
18
by: mike3 | last post by:
Hi. I have an interesting problem. The C program presented below takes around 12 seconds to copy 128 MB of data on my machine. Yet I know the machine can go faster since a copying done at a...
5
by: parthaspanda22 | last post by:
How can I get to discard the contents of a text file from a specified offset( say, obtained from ftell)? Sincerely.
13
by: writeson | last post by:
Hi all, I'm writing some code that monitors a directory for the appearance of files from a workflow. When those files appear I write a command file to a device that tells the device how to...
4
by: Tom | last post by:
I am trying to update another developers code, and am stuck in a cludge. It works like this: A user uploads a file from the web page. Our code reads from a NetworkStream to a Filestream, and...
7
by: Simon van Beek | last post by:
Dear reader, How can I make a copy from a database which is in use. If an mdb database is in use Access opens a small file with the extension ldb. This ldb file prohibits the execution...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.