473,765 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: Insert character at a fixed position of lines


Francesco Pietra wrote:
How to insert letter "A" on each line (of a very long list of lines)
at position 22, i.e., one space after "LEU", leaving all other
characters at the same position as in the original example:
ATOM 1 N LEU 1 146.615 40.494 103.776 1.00 73.04 1SG 2

In all lines"ATOM" is constant as to both position and string, while
"LEU" is constant as to position only, i.e., "LEU" may be replaced by
three different uppercase letters. Therefore, the most direct
indication would be position 22.
you may find the fileinput module helpful, combined with the tips you've
already gotten in this thread.

reference:

http://docs.python.org/lib/module-fileinput.html

examples:

http://effbot.org/librarybook/fileinput.htm
http://blog.doughellmann.com/2007/03...fileinput.html

</F>

Jul 26 '08 #1
0 883

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

Similar topics

3
2331
by: Dennis Craven | last post by:
Hello, Does anyone know how one could insert a backspace into a widget such as a TextView/Buffer in Pygtk? Whenever I try something like insert(iter, '\b') I get jibberish inserted into the buffer. Thanks, ~djc
1
11858
by: Vitabiz Productions Ltd | last post by:
Hello, I'm currently experiencing some problems with the following code: <TABLE border=1 cellpadding=0 cellspacing=0> <TR> <TD BACKGROUND="images/menu.gif" WIDTH="170px" HEIGHT="372px" VALIGN=TOP>&nbsp;</TD> <TD BACKGROUND="images/content.gif" WIDTH="630px" VALIGN=TOP rowspan="2"> Some text lines<br>Some text lines<br>Some text lines<br>
6
3633
by: Marie ALHOMME | last post by:
Hi everybody ! I'm new here, and I'm French, so pardon me for any and all grammar and typo mistakes ! I hope you'll understand everything anyway :) I'm working on my portfolio site, which I am completely rewriting in HTML 4. strict + CSS. In the Gallery part of the site, people can see thumbnails of my work and when they click on any work, it opens a popup (btw : I'm not here to
25
36366
by: Michael Schuerig | last post by:
I'm trying to do something seemingly very simple, but it's brought me close to crushing my head on the keyboard. All I want is a table where the head row is fixed and the body columns below are scrollable (with the ordinary scrollbars, no less). Whatever I try, the columns in the head and the body aren't aligned; the widths are computed independently which gives a completely ragged look. Michael --
7
14784
by: tano | last post by:
Hello, I have to insert a char in the middle of a string, I have written two functions but I don't know what is the better? The problem is: if I use malloc() I copy all the string with the new char in the middle every time, with realloc() the part of the string before the position where the char has to be inserted is not changed if realloc returns the same pointer is passed, but if not the string is copied at all the first time, and then...
4
5031
by: neilcancer | last post by:
i wrote a function to insert an elem into a list, but it was wrong,wrong,wrong! and i have no idea about why it was wrong. If anyone know, leave your advice, thank you. #include<stdio.h> #include<stdlib.h> typedef struct lnode { int elem;
24
4853
by: garyusenet | last post by:
I'm working on a data file and can't find any common delimmiters in the file to indicate the end of one row of data and the start of the next. Rows are not on individual lines but run accross multiple lines. It would appear though that every distinct set of data starts with a 'code' that is always the 25 characters long. The text is variable however. Assuming i've read the contents of the file into the string myfile, how do i split my...
8
5027
by: Red | last post by:
If auto-format is turned off in VS2008, there is apparently no way to indent a line. Under Tools->Options->Text Editor->C#->Formatting, there are three checkboxes. Unchecking those seems to cause this behavior. I'd simply like to have the tab key insert a tab at the beginning of a line. I believe that there were publlished macros for doing this in earlier VS versions, but I expected this to be 'fixed' in VS2008. Yes, I realize someone...
7
2776
by: Francesco Pietra | last post by:
How to insert letter "A" on each line (of a very long list of lines) at position 22, i.e., one space after "LEU", leaving all other characters at the same position as in the original example: ATOM 1 N LEU 1 146.615 40.494 103.776 1.00 73.04 1SG 2 In all lines"ATOM" is constant as to both position and string, while "LEU" is constant as to position only, i.e., "LEU" may be replaced by three different uppercase...
0
9398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9951
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7378
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.