ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

[Solved] Manipulate lines in a txt file

<< < (2/9) > >>

Ath:
In NANY 2014 there was TIMU by phitsc, but I couldn't get it to remove the first phrase or empty lines.

Just download awk (or gawk) for windows (command-line tool) and run it using the command I've shown above... :tellme:

Ath:
See below, Reply #18, for a better working, 4 step, solution, using NotePad++

Here's a '3-step' Notepad++ solution:

Settings for Replace dialog (Ctrl-H):
Search mode: Regular expression
. matches newline: Off (=not checked)

Step 1: (Remove all first phrases, trim any leading white-space from the remaining part)

--- ---Find what: [^\.]*?\.\s*(.*)
Replace with: $1\nPress Replace all button

Step 2: (Replace all remaining phrases by the phrase and a new-line, removing any white-space in front of a phrase)

--- ---Find what: \s*([^\.]*?\.)
Replace with: $1\nPress Replace all button

There are other issues with these type of free texts, the (short) example contains shortened words like St. and Dr. that cause excess line-breaks to be inserted. These can be fixed by adding another step to the Notepad++ recipe:
Step 3: (Restore shortened words with their second part)

--- ---Find what: (St\.|Dr\.)\n
Replace with: $1Press Replace all button
Done :D

If more shortened words are found, add them to Find what within the round braces, prefixed with a vertical pipe, like this for adding "Mt.":

--- ---Find what: (St\.|Dr\.|Mt\.)\n
Remember: It replaces the file-contents, so either work on a copy or use Save as... if the original file needs to be preserved.

PS: Tested using Notepad++ 7.2.2 and EditPad Lite 7.5

NB: please report how it's working for your file(s) so the thread can be moved to Resolved when satisfactory.

Edit: Updated step 1 to remove leading white-space of the remaining text.
Edit2: Added step 3 to restore 'unintended' line-breaks after shortened words like Dr., St., etc.
Edit2: Replaced \1 substitutions by more generic $1.
Edit2: Also tested with EditPad Lite. PSPad isn't capable of doing step 3, so I'd advise to not use PSPad!
Edit3: Superseded by a better 4 step solution, see below, Reply #18

wraith808:
I want to echo one of Ath's requests that still has not been answered... Give us sample data.  It will make this conversation a lot more productive.

Contro:
Here's a '2-step' Notepad++ solution:

Settings for Replace dialog (Ctrl-H):
Search mode: Regular expression
. matches newline: Off (=not checked)

Step 1: (Remove all first phrases)

--- ---Find what: [^\.]*?\.(.*)
Replace with: \1\nPress Replace all button

Step 2: (Replace all remaining phrases by the phrase and a new-line, removing any white-space in front of a phrase)

--- ---Find what: \s*([^\.]*?\.)
Replace with: \1\nPress Replace all button
Done :D

Remember: It replaces the file-contents, so either work on a copy or use Save as... if the original file needs to be preserved.

PS: Tested using Notepad++ 7.2.2

NB: please report how it's working for your file(s) so the thread can be moved to Resolved when satisfactory.

-Ath (February 17, 2017, 01:39 PM)
--- End quote ---

I will try and comment Ath. Best Regards

Contro:
The example file is like this with 19000 lines . Each line contains several phrases seperated by periods ("." ) (what i call erronously "points" )
1 line
Hasta aquí esta revisión sobre los conceptos de George Vithoulkas, que resumiendo lleva de nuevo a ratificar que: los síntomas de mayor jerarquía en cada caso individual de enfermedad, son los síntomas del plano mental/espiritual, seguidos por los del plano emocional y por último el plano físico. De ahí la importancia del estudio detallado y profundo de los síntomas que aparecen en el repertorio en el primer capítulo que es Mente o Psiquis.
2 line
El Dr. James Tyler Kent nació en los Estados Unidos de América en Woodhull, New York, el 31 de marzo de 1849, estudió medicina en Eclectic Medical Institute de Cincinati, Ohio y recibió su grado en 1871. Su práctica médica la comenzó a los 26 años en St. Louis, Missouri, y llegó a ser un distinguido miembro de la Eclectic National Medical Association. Su primera esposa había muerto en el año 1877 y Lucy, su segunda esposa, enfermó y fue naturalmente sometida al tratamiento de la época, tanto ortodoxo como ecléctico, pero ella no mostraba mejoría y seguía empeorando, por lo cual se consultó al Dr. Richard Phelan, que era médico homeópata. Éste hizo su prescripción y los síntomas (debilidad nerviosa, insomnio y anemia) desaparecieron rápidamente y la paciente se recuperó totalmente en poco tiempo. Por ese motivo, Kent decidió entonces estudiar homeopatía con el Dr. Phelan y llegó a considerar que la homeopatía “era el único método terapéutico basado en leyes y principios, y el único que se dirigía a la causa fundamental de la enfermedad” (Llobet, 2014). Se convirtió así en un estudioso de la homeopatía, en especial de la 5ª edición del Organon de Hahnemann2 y se convirtió completamente a la nueva escuela. Después de abandonar la Eclectic National Medical Association en 1879, ocupó la cátedra de Homeopatía en el “Homoeopathic Medical College” de St. Louis desde 1883 hasta 1888; fue profesor de Materia Médica en el “Hahnemann Medical College” de Philadelphia y además en el “Hering Medical College Hospital” de Chicago.
3 line
Es y ha sido considerado como uno de los homeópatas más destacados de la escuela de homeopatía norteamericana; fue miembro de varias asociaciones médicas como la “Illinois State Homoeopathic Medical Society”, el “American Institute of Homoeopathy” y la “International Hahnemannian Association” y miembro honorario de la “British Homoeopathic Medical Society”. En 1916, cuando disfrutaba de vacaciones, se agravó una bronquitis crónica que padecía y que luego se complicó con glomerulonefritis y falleció el 6 de junio de ese año en Stevensville (Montana).
4 line
Según el autor de este artículo, Kent fue el creador directo de su Repertorio, mientras que sus otros escritos, fueron una recopilación de los apuntes o notas que sus alumnos tomaban durante las clases que él dictaba.


and so on ....

The target is deleted the first phrase of each line, and then explode the resto of each line or string into seperate phrases by the period.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version