Re-ordering 2 files, can you help me speed it up?
Hi all - this is kind of complicated. I have 2 files, each contains identical blocks of information (identified by the word "Processing") but in different orders. So I have to find the block in the first file, write it to an output file, and then find the matching block in the 2nd file and write it out - Thereby insuring that the processing blocks in both outfiles are in the same order. (What my end result should be is 2 files I can compare, looking for info inside the blocks that may differ).
I've got a function now, but it's sloooooow. The biggest file that I have to read & manipulate like this is 14,406 kb in size. Takes about 15 to 20 minutes and eats up 97% of my resources. The code is below, can anyone help identify bottlenecks? (or better ways to accomplish this...)
Thanks!!!
/* This function reads one file line by line. if a line contains the word "processing",
then another stream is opened (same file, starting at same line), and data is read and
written to the "out" file until "processing" is found again. A 2nd file, with the same
info but in a different order, is opened & searched for the same processing block, this
data is entered into the 2nd out file. This is basically a re-ordering scheme.*/
protected void CrossThem(String outfile1, String outfile2){
/* create the new "clean" files */
String out1 = CreateCleanFile(outfile1);//creates the 1st file that will be written to
String out2 = CreateCleanFile(outfile2);//creates the 2nd file that will be written to
/* create the 3 RandomAccessFiles that will be read from */
RandomAccessFile rf1;
RandomAccessFile rf2;
RandomAccessFile rf3;
try
BufferedWriter bw = new BufferedWriter(new FileWriter(out1, true));
BufferedWriter bw2 = new BufferedWriter(new FileWriter(out2, true));
rf1 = new RandomAccessFile(outfile1, "rw");//1st file to be read from
rf2 = new RandomAccessFile(outfile2, "rw");//1st file to be searched when info is found in rf1
rf3 = new RandomAccessFile(outfile1, "rw");//2nd file to be searched for info found in 1st
String line1 = null;
String line2 = null;
while((line1 = rf1.readLine()) != null){
if (line1.indexOf("Processing")!= -1){
g_fp = rf1.getFilePointer();
String nextline1 = null;
bw.write(line1 + "\n");
rf3.seek(g_fp);
/* get rest of processing block by opening another
* file and starting from there
while(((nextline1 = rf3.readLine()) != null ) && (nextline1.indexOf("Processing") == -1)){
bw.write(nextline1);
bw.write("\n");
/* find block in rf2 */
rf2.seek(0);
while((line2 = rf2.readLine()) != null){
if((line2.equalsIgnoreCase(line1) && (line2.indexOf("Processing") != -1))){
long fp2 = rf2.getFilePointer();
String nextline2 = null;
bw2.write(line2);
bw2.write("\n");
rf2.seek(fp2);
while((nextline2 = rf2.readLine()) != null && (nextline2.indexOf("Processing")== -1)){
bw2.write(nextline2);
bw2.write("\n");
rf1.close();
rf2.close();
rf3.close();
bw.flush();
bw2.flush();
bw.close();
bw2.close();
}catch (Exception o){
//do something
}
I'd suggest one quick and easy thing you can do is not re-scan the second file on each processing block.
During the scan, if it is not the block you want, you could save the file location into a HashMap with the processing line/identifier as the key. You could also save the "furthest" location you've progressed into the file. Then when you get a processing block from the first file, check if it matches one in your HashMap, and immediately seek to that location and process the block. If it's not in the HashMap, seek to the furthest location you saved, and continue scanning procedure, adding processing blocks to the HashMap (again) until you find the block you want.
Similar Messages
-
I can not download any files from my e-mail like office files, can you help me
I can not download any files from my e-mail like office files, can you help me
Which Email app are you using?
-
I have the following Imac and Iphoto 11 in Finder folder I upgrade the iphoto file and I lost all the latest event files, can you help how to solve the problem? Thank you
Model Name: iMac
Model Identifier: iMac8,1 Processor Name: Intel Core 2 Duo
Processor Speed: 2.4 GHzhttp://support.apple.com/kb/HT2638?viewlocale=en_US&locale=en_US
-
The icon wont enable and when I go to open it via "open file" some technical sentences come up that make no sense to me. I don't know what is wrong. Never had this problem before. Can you help?
Sorry, I clicked on the wrong link.
davewdan -
I need information about moving photo files--can you help?
My PC internal hard drive C: is full so I can't add more photos. I discovered the hard drive is partitioned and has another drive D: that is empty and has more than enough space. How do I move all my photos from C: to D: and leave the Elements program and the Catalog on C: and have the organizer recognize where the photos went? This seems to be a different procedure than moving to a new computer. Do I use the Move command? Do I use the Backup and Reconnect procedure? Do I do something else?
RussellWood wrote:
Do I use the Move command? Do I use the Backup and Reconnect procedure?
Both methods are valid.
Using the move command is simpler and quicker. Many users don't recommend it on account of problems in older versions. My own experience is different (PSE12) : while doing speed tests in moving a whole folder tree from one physical drive to another, my computer was struck by a power outage at 95%... the process aborted and I was reverted to the original situation without losing anything. The transaction rollback worked perfectly. Moving to another logical drive is the same.
Using the backup and restore (not reconnect) feature is recommended for an excellent reason : maximum safety : nothing is changed in the original drive, plus you get a backup. Since you have to state a new custom location, the catalog is also restored in the new drive. The process is longer : backup and restore (twice the time compared to move), checking the result on the new drive, deleting the catalog and the media files in the original drive, then using the catalog manager to move the catalog back to C:
My own compromise would be to do a full backup (just in case) then doing the move option.
Do I do something else?
You could... there is the solution to move files externally with the explorer/finder, then using the reconnect feature. There are Lightroom gurus who advocate that procedure : to tell you the truth, I have never got good results in the organizer for big libraries...
I'll just mention for users acquainted with database management that if time is a problem for me, I'll copy all my pictures folder tree with the explorer to the same exact location on the new drive, then I'll use a sqlite utility to update the drive identifier in a copy of the catalog. After checking the result, I'd delete the original folder tree. -
Firefox caching on SWF files (Adobe Flash files) are not caching at browser level. But the same SWF Files are caching at other browsers like Google Chrome and IE.
But when i see the about:cache service information, I can see SWF Files are there in the disk cache device. When ever i hit the same page, the SWF files are downloaded from the server not from the browser, but the fetch count for that SWF file will get increase in disk cache device. So it's taking time to load the SWF files every time when i hit the page.
I'm requesting your help on this SWF File caching.<i>Moderator Comment<br>
(Duplicate thread closed. Continue at [/questions/1000178]) -m) </i> -
Hello as ive said i have lost thousands of itunes music files how can i retrieve them i phoned apple store in Bromley in UK and they confirmed i have 1000sands of usic files but cant download them
Theyn will only be where you put them.
You cannot redownload from another country.
Have you failed to maintain a abckup copy of your music? -
Java icon is on all PDF files, can you help remove it?
Hi From Jomar1952. I cant open PDF files anymore Java is on all PDF files. Action taken: Remove Java files, which now open with A/Reader Java Icon is off all files now. Files open without "open with" actions. thank you
This forum is to discuss the forums, not products
You need to ask your question in the forum for the Adobe product you are using
How to Select a Forum http://forums.adobe.com/docs/DOC-1015 -
Can you help me find pix that I stupidly made a new folder in temp files and now can't find my pictures?
Mac Pro
Using a MacBook Pro
Two different computers. One is a desktop & the latter is a Notebook. Which one are you having issues with?
Which os is installed on your computer?
Please describe in detail all you have attempted to do in order to resolve the issue. How did you "search?" -
I've done everything I know in order to get my calendar in iCloud synchronized with my macBook, my IPad and my iPhone, but get no success. I've checked if all devices are set to the same account. Can you help me?
The only thing I can see strange is that when I login my iCloud account through my principal email address, when I check my preferences is marked an @me.com address that is old and I don't use it anymore, but I can't erase it or even change it.
-
Please can you help....
I ordered an iPhone 5s in early September from the orange shop in Chamonix Mont-Blanc France.
I needed a new phone as i dropped my iPhone and broke it so it thought i would upgrade.
I was asked in the shop if I wanted a black or white one, I asked for a Black one, as all my iPhones have all been Black as I DON'T LIKE White ones. (sorry)
I was told my phone would arrive in a week so I waited with broken phone for new one. The following week I was told it would be the following week, the following week i was told the same but the assistant in the shop told me they would ring me when it arrived. Three days later i recieved a text from the shop to say the phone would be in tomorrow, when I went in they said it had not arrived and they would call me when it was in the shop.
They called me on Thursday the 17th of October to say the phone was in the shop.
I arrived at the shop at 6:00pm after my work, the shop closes at 7:00pm. I recieved the phone, signed for it and extra unwanted insurance with I was told I could only canceled in a month. I was then told they didn't have any sim cards in the shop, i said no problem the Phone i assume will need charging so i will take it home and charge it and return for the sim tomorrow.
So the Phone remained boxed.
When I returned home and opened the box I realised it was a white one, I replaced the lid put it back in the bag, and returned it to the shop first thing Friday 18th October, to point out the error, only to be told "to bad" ?? I was told I could have changed it the night before but not this morning? They said I had ordered a Black one but as I had signed for a White one nothing can be done. I was angry and left the shop. I returned later the same day with a French friend to try and resolve this problem, as I wasn't sure if something was being lost in translation. I didn't think I was being unreasonable, it is a very expensive piece of equipment and this wasn't what i wanted. They told my friend that the phone was not available in Black, that was the 5, and that the 5s was only available in silver and gold, and that mine was a silver one.
I then thought it was my mistake as it was a new phone. She put a sim in the phone put it in the box and I left for a business meeting only to arrive and see a Black iPhone 5s sitting on the table??
So I then returned back to the shop with the Black one and mine still all boxed and untouched to prove they had blatantly lied to me an hour ago, only to be told that there was nothing they were prepared to do.
Is this fair practice ? I am at a loss with this and am looking for help ?Welcome to the Support Communities. This Apple doc may be of interest:
Channel Member Code of Conduct
Kings74 wrote:
They told my friend that the phone was not available in Black, that was the 5, and that the 5s was only available in silver and gold..
A minor point, but it may avoid a little confusion if, instead of saying "black" in reference to the iPhone 5s, say "space gray":
"iPhone 5s — Available in silver, gold, and space gray" (Source) -
My right click is not working and producing the context menu or ability to drag files and folders. I just spoke with a phone support person and we checked that all the mouse/trackpad options for right click were correct and checked.
Please can you help with this.
It has only just happened in the last few days.
Many thanksYou might want to update your profile so that we can see what model iMac you have and what version of OSX you're running.
For this question, it might help to know if you're dealing with a trackpad, Magic Mouse, or something else?
(Until your issue's resolved, you can Control-Left Click to get the right click functionality). -
I have a MacBook pro version 10.6.7 with snow leopard. After an scheduled software upgrade I could not open Quicken (It said it could not open the files). Now I can only open it if I have my external drive on. Can you help?
All the information that I had input on Quicken is gone. I have to have the external hard drive that I use to back up to be able to use quicken now. It is as if it was erased from the laptop hardriveTry repairing permissions. My favorite way is with a utility called AppleJack. Info and download here. It's free. It only works when you boot in Single User Mode. When restarting or booting, hold down the Command key and S keys.
You will get a very different startup screen that looks like the Terminal app has hijacked the screen. Just let the lines of text scroll by. When that happens you will get a text entry prompt. Type in "AppleJack" without the quotation marks.
A DOS looking menu will appear. Choose 1 or d to run Disk Repair. If you get a message that Disk Repair found and corrected errors, run it again. Repeat until you get the "your disk appears to be ok" message. This rarely happens with my experience, though. This does the same thing as as booting from an external drive and running Disk Utility's repair. Only, no external drive is required!
Next, choose 2 or p to repair disk permissions. This will take a little while. AppleJack warns that it will take up to an half hour to run repair permissions. It'n never taken more than about ten minutes for my MacBook Pro.
As permissions are repaired, you will see each repair scroll on the screen. When done, the menu returns, choose q to quit. Then at the prompt, enter "exit" without the quotes. Your MacBook Pro should restart into Mac OS normally after this.
Hope this helps. -
Can you help with rematching file names
After a computer crash needed to reload my library. When doing this I accidently clicked the option to add track numbers to song names.
Later I was able to locate my iTunes XML from my old PC, however many of the songs (5000 out of 6000) no don't match because the original song name has been changed since my stupid error caused the files names to get the song number in front of them.
Anybody have any tips for matching the filenames back up. In my original library some files had track numbers in front and some did not. How can I match them back up. I'm comfortable programming and modifying the iTunes XML but I can't figure out a good way to list out the contents of my hard drive to do the actual matching.
TonyBecause this forum software is so absolutely USELESS now, you don't get to see the whole of the question in this view. In the other (non-list) view it says:
"can you help with a technical problem with the stereo imagery option ? it won't take out lead vocal in a stereo mp3"
And the answer is that if you can't isolate the vocal in the stereo field, or it is one of these odd ones where it's used inverted polarity in different parts of the stereo signal for the same vocal, then you won't be able to. But without a sample, it's impossible to tell. If you can post a link to one, that might help. It has to be external to this site though - Adobe in their infinite wisdom don't allow the posting of audio files on their audio U2U forum. Helpful, that, isn't it? -
On photoshop element 12 when I open a .MTS file I have the sound with a black screen if I open a .mov it work fine I have uninstall and reinstall I still have the same problem can you help?
I have find the codec installed on my PC do you see an undesirable one I have highlighted the one that seems strange should I uninstall how can I do this safely
Daniel
Codecs audio
Type
Nom
Format
Binaire
Version
ACM
Codec Microsoft IMA ADPCM
0011
ACM
CODEC A-Law et u-Law Microsoft CCITT G.711
0007
ACM
Codec audio Microsoft GSM 6.10
0031
ACM
Codec Microsoft ADPCM
0002
ACM
Fraunhofer IIS MPEG Layer-3 Codec (decode only)
0055
ACM
Convertisseur PCM Microsoft
0001
DMO
WMAudio Decoder DMO
0160, 0161, 0162, 0163
WMADMOD.DLL
6.1.7601.17514
DMO
WMAPro over S/PDIF DMO
0162
WMADMOD.DLL
6.1.7601.17514
DMO
WMSpeech Decoder DMO
000A, 000B
WMSPDMOD.DLL
6.1.7601.17514
DMO
MP3 Decoder DMO
0055
mp3dmod.dll
6.1.7600.16385
Codecs vidéo
Type
Nom
Format
Binaire
Version
ICM
Microsoft RLE
MRLE
msrle32.dll
6.1.7601.17514
ICM
Microsoft Vidéo 1
MSVC
msvidc32.dll
6.1.7601.17514
ICM
Microsoft YUV
UYVY
msyuv.dll
6.1.7601.17514
ICM
Codec Intel IYUV
IYUV
iyuv_32.dll
6.1.7601.17514
ICM
Toshiba YUV Codec
Y411
tsbyuv.dll
6.1.7601.17514
ICM
Codec Cinepak de Radius
cvid
iccvid.dll
1.10.0.13
DMO
Mpeg4s Decoder DMO
mp4s, MP4S, m4s2, M4S2, MP4V, mp4v, XVID, xvid, DIVX, DX50
mp4sdecd.dll
6.1.7600.16385
DMO
WMV Screen decoder DMO
MSS1, MSS2
wmvsdecd.dll
6.1.7601.17514
DMO
WMVideo Decoder DMO
WMV1, WMV2, WMV3, WMVA, WVC1, WMVP, WVP2
wmvdecod.dll
6.1.7601.18221
DMO
Mpeg43 Decoder DMO
mp43, MP43
mp43decd.dll
6.1.7600.16385
DMO
Mpeg4 Decoder DMO
MPG4, mpg4, mp42, MP42
mpg4decd.dll
6.1.7600.16385
De : sarika02
Envoyé : 17 juin 2014 19:26
À : Daniel Cloutier
Objet : On photoshop element 12 when I open a .MTS file I have the sound with a black screen if I open a .mov it work fine I have uninstall and reinstall I still have the same problem can you help?
On photoshop element 12 when I open a .MTS file I have the sound with a black screen if I open a .mov it work fine I have uninstall and reinstall I still have the same problem can you help?
created by sarika02 <https://forums.adobe.com/people/sarika02> in Photoshop Elements - View the full discussion <https://forums.adobe.com/message/6466796#6466796>
Maybe you are looking for
-
Can I create a new iFS schema by command line ?
For creating a new iFS Schema you have to run ifsconfig and this is a GUI tool. Is there a way to specify all the parameters to this command by input file so that it can create the schema without popping up the GUI ? If yes how can one catch errors i
-
I purchased a song off iTunes from iPhone, but has not synced with Library on home computer
iTunes oh iPhone is not syncing with iTunes on home computer
-
SamplesApp from BEA Weblogic Workshop :handling data, binary Flow
Hi, Everything is fine if I want to upload an image, but I would like to upload another kind of file in a database, PDF for example, how I can access it after uploading and saving in a database? Are amy examples about this? Any help is appreciated. T
-
If i wan to sell my ipod touch do i need to change my apple id?
if i wan to sell my ipod touch do i need to change my apple id or itunes store Id? i scare people will misused my id and personal information.
-
Reporting tools for users in 10.7?
I am new to Oracle, I come from the PeopleSoft side. PS has a great tool (PS Query) where users can create queries, and either view results online, or run the results to a spreadsheet, or even a Crystal report. Is there any comparable tool in Oracle