Need to, in steps, copy/cut/paste
-
Hi!
I’m only reaching out to see if my problem could be solved with Notepad++. Otherwise i need to check other solutions.
I’ve downloaded a software i would like to try out but it does not come in my native swedish language, and no surprice, there are 3 huge files with each around 13000 rows to translate. :o
To my problem.
- I’m trying to use Notepad++ to copy what ever is in the noteID (nid) to the notestring (nstr).
- Now when the nid and the nstr are identical i then need to remove/save nid (temporarly to another location/notepad) in order to be able to translate the nstr into swedish which im quickly doing with google translate (i will correct the far lesser percentage faults later). Why i need to remove nid is because when i do a translate ‘batch-style’ both nid and nstr will be translated, and that cannot happen.
- When nstr is translated i then need to put back/add the nid what i previously in step 2 removed, back to where it previously was locate (the row over nstr) which the software use to work properly.
If i’ve complicated things with my steps above then feel free to advice me a better way.
Example:
1.
nid “Name”
nstr “”nid “Address”
nstr “”nid “City”
nstr “”nid “E-mail address”
nstr “”nid “Phone number”
nstr “”nid “Name”
nstr “Name”nid “Address”
nstr “Address”nid “City”
nstr “City”nid “E-mail address”
nstr “E-mail address”nid “Phone number”
nstr “Phone number”nid “Name”
nstr “Namn”nid “Address”
nstr “Adress”nid “City”
nstr “Stad”nid “E-mail address”
nstr “E-postadress”nid “Phone number”
nstr “Telefon nummer”Any help appreciated.
Thanks. -
Make a backup of your data in case something goes wrong.
- duplicate string contents
- FIND WHAT =
(?-s)^nid (".*")\r\nnstr ""
REPLACE WITH =nid $1\r\nnstr $1
SEARCH MODE = Regular Expression - REPLACE ALL
- FIND WHAT =
- Number the lines:
Ctrl+Home
- Edit > Begin/End Select in Column Mode
Ctrl+End
- If you aren’t at the end of a line, hit ENTER to create a new blank line at the end of the document
- Edit > Begin/End Select in Column Mode to finish the column selection – you should have a tall, super-thin rectangle selected
- Type a space character to indent by one
- Down Arrow to leave column-selection, then left arrow to get to the left edge of the last line
- Edit > Begin/End Select in Column Mode
Ctrl+Home
- Edit > Begin/End Select in Column Mode to end selection, again giving a zero-width but tall selection
Alt+C
(or Edit > Column Editor) to pop up the Column Editor dialog.- Insert number, initial =
1
, increase = ``, leading =None
- the file should be numbered, with one or more spaces to the right of each number (depending on the number of digits)
- Bookmark and cut the
nstr
linesCtrl+M
(Search > Mark)- FIND WHAT =
\bnstr\b
(the\b
make sure thatnstr
will be a whole word, not part of some other word)
☑ BOOKMARK LINE
MARK ALL - There should now be a dot on each line with
nstr
highlighted
- Search > Bookmark > Cut Bookmarked Lines
- Put the
nstr
lines in a new docCtrl+N
Ctrl+V
- Outside of Notepad++: Translate that new document (making sure they are still numbered; spaces don’t matter, as long as there’s at least one space after the number)
- Copy the translated lines
- Paste at the end of your original document (which currently just has numbered
nid
lines) - Edit > Line Operations > Sort Lines as Integers Ascending
- remove the line numbering
- FIND WHAT =
^\d+\h+
REPLACE WITH = delete the field, so you will replace with empty string
SEARCH MODE = Regular Expression
REPLACE ALL
- FIND WHAT =
- duplicate string contents
-
@PeterJones
Hi Peter…A huge thank you to a very well done job, i cannot thank you enough. Your instructions worked like a charm with some minor tweaks on the regex you gave me…
- (?-s)^nid (".“)\r\nnstr “”* didn’t work for me, so i tried it bit by bit and this > (?-s)^nid (".”)\nnstr “”* worked much better.
- That instruction… "initial = 1, increase = ``, leading = none… the increase part didn’t work for me either, the box didn’t allow me to add those characters, so when i tried without i only got 1’s all the way down… that didn’t work so the most logic for me was to give increase the value of 1, then it worked.
- And that \bnstr \b didn’t work too, so i removed the last \b then i was back on track. :)
I was slightly curious about how the end would look like, but there was no problems at all… everything went smooth as butter… :)
But i had some other problems with the file to deal with first, after copying some rows in the beginning i noticed the english was messed up, where 450 rows were not inside the quotation marks… like this…
nid “”
“Are you sure”
“you want to clear the reportings”
nstr “”nid “”
“Are you sure”
“you want to clean”
“up duplicates”
nstr “”nid “”
“Are you sure”
"you want to “clear”\ or “save”
“expired items”
nstr “”nid “”
“Are you sure”
“you want to”
“clear offensive”
“items”
nstr “”so i needed to take care that first… removing all the extra quotation marks… when i did that i noticed half way in the file im editing everything wrong… you see i removed all the quotation marks, even those inside sentences (“%s” and target=“_blank”)… which is bad… so i had to start all over again… it was the first step of 4 instead of 3.
Ja, ja… as we say here… “When head is stupid, body will suffer” (hence the unnecessary extra job)… :/
A huge thx again Peter… :)
-
@Bertil-Wallman said in Need to, in steps, copy/cut/paste:
@PeterJones
Hi Peter…- (?-s)^nid (".“)\r\nnstr “”* didn’t work for me, so i tried it bit by bit and this > (?-s)^nid (".”)\nnstr “”* worked much better.
Notepad++ is a Windows text editor, so assuming Windows line endings is natural, and works for the majority of the people; if you had mentioned that you were using Linux line endings, I would have customized the expression for your actual data.
- That instruction… "initial = 1, increase = ``, leading = none… the increase part didn’t work for me either, the box didn’t allow me to add those characters,
That was a typo on my part. It should have said “increase =
1
” – I just missed the 1 in between the ` characters for trying to make the 1 red like1
.- And that \bnstr \b didn’t work too, so i removed the last \b then i was back on track. :)
There was no space between the
str
and the\b
in my example. In my testing, I literally used\bnstr\b
and it worked. If you used\bnstr \b
, it would not work, because the next character after the space is a"
, and between the space and the quote mark is not a word-boundary.But i had some other problems with the file to deal with first, …
Glad you figured it out.