473,406 Members | 2,698 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,406 software developers and data experts.

how to edit data from a file using fgets or other comands

I want to edit a PDB file (Protein Data Bank ) using C programming language and I am using a linux platform. I donot know much about the language but want to append some columns in another file keeping the rest same .I have developed the portion on editing the Specific columns but I donot know the file structure and related programming , my data looks like

ATOM 45400 P U B2016 77.414 -57.257-103.840 1.00 19.24 P
ATOM 45401 O1P U B2016 78.179 -55.989-103.907 1.00 19.24 O
ATOM 45402 O2P U B2016 76.569 -57.674-104.987 1.00 19.24 O
ATOM 45403 O5* U B2016 78.427 -58.428-103.470 1.00 19.24 O
ATOM 45404 C5* U B2016 79.420 -58.250-102.460 1.00 19.24 C
ATOM 45405 C4* U B2016 80.183 -59.534-102.266 1.00 19.24 C
ATOM 45406 O4* U B2016 79.239 -60.563-101.883 1.00 19.24 O
ATOM 45407 C3* U B2016 80.883 -60.055-103.502 1.00 19.24 C
ATOM 45408 O3* U B2016 82.212 -59.535-103.483 1.00 19.24 O
ATOM 45409 C2* U B2016 80.854 -61.569-103.322 1.00 19.24 C
ATOM 45410 O2* U B2016 81.937 -62.041-102.548 1.00 19.24 O
ATOM 45411 C1* U B2016 79.551 -61.773-102.543 1.00 19.24 C
ATOM 45412 N1 U B2016 78.381 -62.149-103.349 1.00 81.32 N

the data is in tabular form and i want to append the five numeric columns on the right and keep the rest as same . someone told me to use fgets but i donot know . please suggest a detailed suitable program for the same
Jun 29 '07 #1
2 1395
niskin
109 100+
please suggest a detailed suitable program for the same
I'm afraid we can't write the program for you. You would use fgets to read the data into a variable and then, in a loop, you can write that variable into your other file.
Jun 29 '07 #2
niskin
109 100+
It sounds like you also might want to use fseek() to be able to read the numeric columns into a variable rather than everything. Sorry I can't be of more help on this.
Jun 29 '07 #3

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

Similar topics

12
by: aa | last post by:
I am trying to read a.php file from another PHP file using fgets() and display its contents. As a.php starts with <? the browser IE6 does not show anything, although I can see all the contents in...
40
by: googler | last post by:
I'm trying to read from an input text file and print it out. I can do this by reading each character, but I want to implement it in a more efficient way. So I thought my program should read one...
4
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml...
9
by: Adi | last post by:
Hello eveyone, I wanna ask a very simple question here (as it was quite disturbing me for a long time.) My problem is to read a file line by line. I've tried following implementations but still...
3
by: zbenta | last post by:
Hi you guys. I need some help with a program I've written. I can not seam to find the reason for the error that ocurrs. But let me explain. I have a txt file that works as a database to store...
9
by: Justme | last post by:
Novice programmer needs help with using fgets to read and ignore the first two lines of a file. I've gone thru the previous posting regarding fgets, but none of them seems to help my situation. I...
2
by: Rob111b | last post by:
Hi there, I need to make a piece of code in C that 1. opens a specified file, 2. Reads the data in the file and separates it as shown below, 3. Converts the strings into integers and then...
12
by: arnuld | last post by:
WANTED: Even if I do Ctrl-C in the middle of fgets(), fwrite() should write the previously entered data to a file (except if I hit the file-size limit) PROBLEM: If I do a Ctrl-C in the...
30
by: George | last post by:
1 0001000000000000001 2 0001000000000000001 3 10000011001000000000000001 4 10000011001000000000000001 5 10000011001000000000000001 6 10000011001000000000000001 7 ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...
0
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...

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.