473,320 Members | 1,831 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,320 software developers and data experts.

Truncate beginning of a file

file.truncate(X) will truncate the file to at most X bytes (i.e. leave
the first X bytes of the file and throw away the rest). Is there a way
to throw away, say, the first X bytes of the file, and leave the rest?
(Without opening the same file for reading, reading and processing,
overwriting the file with the new processed data, etc.)
Jun 27 '08 #1
2 3358
On Sun, 04 May 2008 22:06:42 -0700, s0suk3 wrote:
file.truncate(X) will truncate the file to at most X bytes (i.e. leave
the first X bytes of the file and throw away the rest). Is there a way
to throw away, say, the first X bytes of the file, and leave the rest?
(Without opening the same file for reading, reading and processing,
overwriting the file with the new processed data, etc.)
No.

Ciao,
Marc 'BlackJack' Rintsch
Jun 27 '08 #2
s0****@gmail.com writes:
file.truncate(X) will truncate the file to at most X bytes (i.e.
leave the first X bytes of the file and throw away the rest).
Yes, by (IIRC) asking the filesystem to do this in a simple operation.
Most (all?) filesystems support this operation either directly or with
little effort.
Is there a way to throw away, say, the first X bytes of the file,
and leave the rest? (Without opening the same file for reading,
reading and processing, overwriting the file with the new processed
data, etc.)
I don't know of any filesystem that supports this operation without
reading the file data. The built-in 'file' type doesn't support it.

--
\ "It's easy to play any musical instrument: all you have to do |
`\ is touch the right key at the right time and the instrument |
_o__) will play itself." -- Johann Sebastian Bach |
Ben Finney
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Yannick Turgeon | last post by:
Hello all, I just started to use perl and I'm having a Regexp question: Say we've got a file with this in it: ---- Beginning of file after this line -------- My list A: cat B: dog C: horse
1
by: New MSSQL DBA | last post by:
I have recently been assigned to take over several MSSQL environments and found some of the existing practice confusing. As most of my previous experiences are on Oracle and Unix platform so would...
4
by: Amit Kulkarni | last post by:
Hi, I have small problem. I want to truncate a line in a text file using C file handling functions and write new line in place of it. How do I do it? e.g. "example.txt" Line 1: This is a...
1
by: venkat | last post by:
Hi, Can any one tell me the best way to truncate a file if it exceeds a specified file size? I need to truncate the start of the file by the appropriate amount (The data to insert). Is there any...
5
by: ronin 47th | last post by:
Hi group, In one of the books 'Gurus Guide to Transact SQL' i found this info: ------------------------------------------------------------ TRUNCATE TABLE empties a table without logging row...
1
by: hedgracer | last post by:
I would like to allow a particular user to truncate a log file in a stored procedure that the user runs every day. At this moment the only personnel that can truncate the log file are personnel...
0
by: Eric Davidson | last post by:
I am try to find a way to get load to reject a record if the data is too large and not just truncate it. eg. c:\temp\fred3.txt ------ a23456789012345678901234567890...
13
by: Hongyu | last post by:
Hi, I have a datetime char string returned from ctime_r, and it is in the format like ""Wed Jun 30 21:49:08 1993\n\0", which has 26 chars including the last terminate char '\0', and i would...
5
by: Timothy Madden | last post by:
Hello I see there is now why to truncate a file (in C or C++) and that I have to use platform-specific functions for truncating files. Anyone knows why ? I mean C/C++ evolved over many years...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
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...
0
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....

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.