Messages - BigVent [ switch to compact view ]

Pages: prev1 [2] 3 4 5 6 7 8next
6
N.A.N.Y. 2014 / Re: N.A.N.Y 2014 Submission: FTP File Uploader
« on: January 17, 2014, 04:06 PM »
Very cool that this got reviewed & could help someone out.  Thank you for the notice!

Sorry for the delay kyrathaba, nothing at the moment works besides cURL. 

7
Either way gentlemen... Thank you for the banter.

MilesAhead - thanks for being a good sport. The tools you suggested are great. I downloaded & agree.

Tao - I scan everything to a single file... But that's just me. Handle it all at once & done.

We're just geeks plain and simple. All ways work.  :Thmbsup:

OP: if you're still reading... Find the way you prefer & roll with it.

There are many many ways to take care of what you need.


8
 :huh:

"Why would you jump to that conclusion?  He says he scanned a thousand songs.  I'd say it was a safer assumption that he has 1000 files." - MilesAhead

"I'm creating a hymn book. The book I scanned and OCR'd had all the songs as blocks, with capitals only at the beginning of a sentence." - OP

He didn't say I scanned *several* books... but "THE BOOK".  Ergo, my assumption.  I could ask why you thought he had thousands of items and call you out on the boards for poorly reading what he wrote... but frankly I don't care.


It's good to have for cases where an already debugged one-liner may save you a ton of work.

That's awesome!  Perhaps I learned something from my 15 minutes of work on this script.   8)

9
Notes:
  • We can only assume that the OP has one single file.
  • I ran this new script on a 105,400 line txt file.  It returned in 1800 ms. (txt file is 6525 KB)
  • Fixed leading white spaces... under the assumption that the OP had leading white spaces on lines.
  • Target's method used is a little faster. Since it's a "once and done" project either method should suffice.

Anyway, Good Luck stormproof!

Code: Autohotkey [Select]
  1. SetWorkingDir %A_ScriptDir%
  2.  
  3. ;// OP -> "The book I scanned and OCR'd had all the songs as blocks, with capitals only at the beginning of a sentence."
  4. ;// We can only assume it's ONE single file
  5. FileSelectFile, SelectedFile, 3, , Open a file, Text Documents (*.txt; *.doc)
  6. if SelectedFile =
  7. {
  8.     MsgBox, You didn't select a file.
  9.                 exitapp
  10. }
  11. else
  12. {
  13.         FileRead, orig_str, %SelectedFile%
  14.         loop, parse, orig_str, `n, `r
  15.         {
  16.                 if (A_LoopField != "")
  17.                 {
  18.                         word_array := StrSplit(A_LoopField, A_Space)
  19.                        
  20.                         ;// fixed leading whitespace but is ONLY an assumption that one exists
  21.                         ;// IF there's not a white space
  22.                         if (word_array[1] != "")
  23.                         {
  24.                                 str := word_array[1]
  25.                                 StringUpper,str,str,T
  26.                                 word_array[1] := str
  27.                         }
  28.                         else
  29.                         {
  30.                                 str := word_array[2]
  31.                                 StringUpper,str,str,T
  32.                                 word_array[2] := str
  33.                         }
  34.                        
  35.                         ;// Rebuild the string and append to temp_var
  36.                         loop % word_array.MaxIndex()
  37.                         {
  38.                                 if (word_array[a_index] = "")
  39.                                         continue
  40.                                 temp_var .= word_array[a_index] " "
  41.                         }
  42.                         temp_var .= "`n"
  43.                 }
  44.         }
  45. }
  46.  
  47. IfExist, Output_File.txt
  48.         FileDelete, Output_File.txt
  49. FileAppend, %temp_var%, Output_File.txt
  50.  
  51. Run, Output_File.txt
  52.        
  53. esc::
  54.         critical
  55.         exitapp
  56. return

10
 Modify as needed.  :Thmbsup:

HTH's


Code: Autohotkey [Select]
  1.  
  2. ;//replace this string with your fileread, string, ...
  3. ;//FileRead, orig_str, C:\My Documents\My File.txt  ;//<== if this is used then the "join" just below this needs to be deleted
  4. ;//*from here*
  5. orig_str=
  6. (
  7. i'm creating a hymn book.  The book I scanned and OCR'd had all the songs as blocks, with capitals only at the beginning of a sentence.
  8. whereas I want to put a capital at the start of every line.
  9.  
  10. there are just under a thousand songs so I don't want to do it by hand!!
  11.  
  12. any ideas?  I've looked on line and can't find anything except via MS Word, which can be configured to do it after every carriage return.
  13. but as far as I can see, only as you type.
  14.  
  15. is there a way to replace every "carriage return" with "carriage return and capitalise the next letter"?
  16. )
  17. ;//*To here*
  18.  
  19. msgbox, Original text used:`n`n`n%orig_str%
  20.  
  21. loop, parse, orig_str, `n, `r
  22. {
  23.         if (A_LoopField != "")
  24.         {
  25.                 word_array := StrSplit(A_LoopField, A_Space)
  26.                                        
  27.                 str := word_array[1]
  28.                 StringUpper,str,str,T
  29.                                
  30.                 word_array[1] := str
  31.                
  32.                 loop % word_array.MaxIndex()
  33.                 {
  34.                         temp_var .= word_array[a_index] " "
  35.                 }
  36.                 temp_var .= "`n`n"
  37.         }
  38. }
  39.  
  40. msgbox, Final Result:`n`n`n%temp_var%
  41.  
  42. esc::

Pages: prev1 [2] 3 4 5 6 7 8next
Go to full version