473,804 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

comparing two output lines.

281 Contributor
I need help on comparing lines in my output file...
How to delete the second line in text file (FileReader) and print out the first line for the same fileno?

I put here sample of my output file:

1 : 30 at 2
1 : 134 at 10
2 : 35 at 2
4 : 30 at 2
4 : 80 at 8
..........
...........

The problem here is, not all file numbers ([0]) have same file numbers.
What I can think is something like this..but I still got the repeated fileno in my new output file.

Expand|Select|Wrap|Line Numbers
  1. lineFRST = in1.readLine(); 
  2. lineSEC = in1.readLine();      
  3.  
  4. while((lineFRST != null) && (lineSEC != null))   {    
  5. ...
  6. String[] thelineFRST = lineFRST.split(" ");
  7. String fileNo1 = thelineFRST[0];
  8.  
  9. String[] thelineSEC = lineSEC.split(" ");
  10. String fileNo2 = thelineSEC[0];
  11.  
  12. if(fileNo1.equals(fileNo2)) {
  13.                printWriter.println(lineFRST); 
  14.             }
  15.             else     {  
  16.                 printWriter.println(lineFRST); 
  17.                 printWriter.println(lineSEC); 
  18.             } 
  19.  
My new output should look like this:
1 : 30 at 2
2 : 35 at 2
4 : 30 at 2


Kindly please teach me...Thank you ....
May 15 '07 #1
0 1098

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

Similar topics

1
2978
by: Doug | last post by:
I need to compare two "address" structures within a document, and perform some action if they are not equal. The XML document is a purchase order, with an address at both the header and line item level: <Order> <Header> ... other header level stuff ... <Address>
3
2046
by: Robert Dell | last post by:
I have a problem comparing strings in an order form i'm writing. I want to give a running total at the bottom of the page and it appears to be working except it doesn't compare correctly (it always adds things up when you didn't select them) so i only added 2 of the items until I got it worked out. here's the page source (you can look at it yourself at http://robertdell.dyndns.org/shifts/ <!DOCTYPE HTML PUBLIC> <html> <head>
7
1711
by: Chéraaar | last post by:
Hi, I have the following problem: In one file (addresses) I have a bunch of lines like this: New 0x8048240 Old 0x0: jne 804824a New 0x8048253 Old 0x0: je 8048293 New 0x80482c7 Old 0x0: jp 80482e0 ....
6
3624
by: Holger Kasten | last post by:
Hello, I am looking for a fast and efficient way to compare two text files and create a thrid one. E.g. Input file 1: Number 1 Number 2
8
7520
by: Frost | last post by:
Hi All, I am a newbie i have written a c program on unix for line by line comparison for two files now could some one help on how i could do word by word comparison in case both lines have the same words but in jumbled order they should match and print only the dissimilar lines.The program also checks for multiple entries of the same line. Here file 2 converts to file 3 which is in the format of file1 and i compare file1 with file3.
3
4317
by: s99999999s2003 | last post by:
hi i wrote some code to compare 2 files. One is the base file, the other file i got from somewhere. I need to compare this file against the base, eg base file abc def ghi eg another file
2
2746
by: TamaThps | last post by:
I have to write a program that takes the lines of code from a .cpp as a string into an array. Then I need to compute the ratio of total lines of code to the number of comment lines, and ratio of total number of non comment and non blank lines to the total number of code. This is the void function that I am using to get these ratio's. void CommentEvaluation(/* in */ string codeArray, int size, ofstream& dataOut) //This function computes the...
1
5034
by: xtremebass | last post by:
Hi Bytes.. In Linux, How can i get return value of comparing two files using the command cmp in the prompt.. when i was tried, it shows only output of unmatched lines(differ line )/ shows nothing if two file are same. please do help.. Thanks.
1
2335
by: Avi1 | last post by:
Hi, I got the code (from the internet)for comparing two files and showing the difference in contents.Now,I tried the same code for two files written in japanese language(kanji).If I save the two japanese .txt files in ANSI format,it works fine,but, if I save them in formats like 'UTF-8','unicode','unicode bigendian',it doesn't show the differences properly....keeps showing odd symbols instead of the japanese characters. Would be glad if...
0
9595
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
10604
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
10359
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,...
1
7643
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
5536
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...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
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
3837
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3005
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.