I am struggling with a translation dilemma, I have been researching for hrs for answers, but i havent found the right one for my issue, and i do not know why i am getting this error:
Translate: Unquoted fields do not allow \r or \n (line 1)
Problem:
I have a translation set in logstash as below:
translate {
field => "module_id"
destination => "module_name_eng"
dictionary_path => "........./translation/translate_module.csv"
}
My translation file looks like this:
120,XXXX
778,YYYY
Also enclosed:
I have no extra char after the first line.
Interestingly the very same file with one line is working, but when i add a new (so with 2 lines) I am getting the above error: Translate: Unquoted fields do not allow \r or \n (line 1)
I really do not understand why, obviously i am doing something wrong, but what it is?
Please help, it is driving me crazy, I have tried almost everything in the file now.
Thank you.
For now it is solved with yml file, since Excel is just not working
Just in case anyone comes across this problem (happened to me when going from LS 6.6. to 6.8.). Converting the line ends from \r \n (0xOD 0xOA) to \n fixed the problem for me.
Related
I am running puppet 3.8.6
In a template, I need to truncate the last four characters then remove hyphens from a string parameter. For example "foo-bar.txt" should become "foobar".
val[0..-5] works for truncating the last four characters.
val.gsub('-','') works for removing the hyphen.
But this is a syntax error.
val[0..-5].gsub('-','')
How can I do both?
I agree with the comment on your post... I don't think your example would produce a syntax error. However, though this is a little more verbose, I find splitting to be easier to reason about than removing slices of the string. This ought to work, too:
val.split('.')[0].gsub('-','')
Edit: I somehow missed that this was inside a template. Oops! I've updated as Alex Harvey suggested in the comments.
I mainly use curly brackets { } to move around in vim when I'm working on something. However, sometimes it will skip too many lines. I assume this is because there is no paragraph break, because if I go put new lines in, I can skip to those. This is mainly an issue when working on HTML that I didn't type or after pasting in some lines. It is very annoying when it skips too many lines for me to see what's between where I started and where I ended.
I hope I've described this well enough for some of you to know what I'm talking about.
Is there a remedy for this other than going through using j and adding line breaks? It's a huge hassle and blow to productivity when having to do this.
EDIT: I wanted to mention I only use the curly brackets to get close to pieces I need to work on. After I am close, I use other means.
That sounds like an issue where some lines contain only whitespace, and so don't get counted as paragraph breaks, even though they look like they should. Since it's only an issue in a few situations, I'd suggest just running a substitution to clean up those lines whenever you notice that it's a problem. For example:
%s/^\s*$//g
To translate what the regex means:
^ match the start of a line
\s* match any number of whitespace characters
$ match the end of the line
So it matches anything that contains only whitespace between the start and end of the line, and replaces it with nothing (note that replacing $ does not overwrite the newline character).
I am trying to run this command in vi
:s/href="\//href="http:\/\/website.com\/folder\/subfolder\//g
but got this error E486: Pattern not found: href="\/
What am i doing wrong?
That error means pretty much what it says. vi didn't find any pattern href="/ (ignoring escapes) in your file.
Sometimes it's easier to use something besides / for the search delimiter if your search has a lot of slashes, so you don't need to escape them all. Try replacing the / delimiter with # instead, like this:
s#href="/#href="http://website.com/folder/subfolder/#g
Then maybe you can more easily see what's wrong with your pattern:
becouse there are many '/' chars, try use another delimiter, ex ',':
:s,some/pattern/with/slashes,new/string,g
On another note. That substition worked for me. Just copied and pasted. Are you on the same line that you are trying to perform the substitution on? the 'g' is meant globally on the line you are on. If you need to perform the search and replace on the file the use :%s/
I've got a bunch of really big files that contain lines like:
convert ./1776/07/04/T915002.tif ./1776/07/04/T915002.png
rm ./1776/07/04/T915002.tif
convert ./1776/07/04/T918012.tif ./1776/07/04/T918012.png
rm ./1776/07/04/T918012.tif
What I want to do is search for say /1861/ meaning a line for the year 1861
But vim seems to interpret that 'go to line 1861, which is not at all what I want.
Searching for the ./1861/ fails too. I assume the leading dot tried to match any character. Trying to backslash quote it fails too. Clearly I'm missing a fundamental idea or two.
Thanks
You need a backslash to escape the dot or the slash:
/\.\/1861\/
Use ? to search backwards. This means you don't need to escape the /s.
?/1861/
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
This produces output page OK
$mystring = "<<<EOT";
Replacing it with the following produces
Parse error: syntax error, unexpected $end in file.php on line 737
$mystring = <<<EOT
This is some PHP text.
It is completely free
I can use "double quotes"
and 'single quotes',
plus $variables too, which will
be properly converted to their values,
you can even type EOT, as long as it
is not alone on a line, like this:
EOT;
Any ideas as to what is causing the parser to choke?
I'm using PHP 4.4.7.
It is only on one file that this behaviour happens all others follow the PHP defined functionality.
What I am trying to recitify is what could be possibly wrong in the proceding lines so that the PHP parser shows in this failure.
John
changed file contents to :-
<?php
$mystring = <<<WHATEVER
This is some PHP text.
WHATEVER;
?>
result =
Parse error: syntax error, unexpected $end in file.php on line 5
Any clues
EDIT
original error was to do with T_ENCAPSED_AND_WHITESPACE this can be caused with jQuery for example "if(x == y){$('#my_image').hide():}" is within the heredoc the bigram "{$ will start the parser looking for php variable for substitution.
EDIT
2 good responses.
1) Ch4m3l3on - "<?php" vs "<?" handling.
2) The Disintegrator - <q>had a similar problem with a stupid program that insisted in putting the BOM in a utf-8 file (ignoring preferences)</q>.
EDIT
1) Replacing all content with a single block didn't fix the problem or give any other pointers.
2) No BOM (Byte Order Mark), pity as this or similar majic characters would have explained all symptoms perfectly.
you have to place your ending heredoc at the beginning of line. if you use some IDE that have indentation, remove them! your ending heredoc must be vertically in the same line as your ending php tag(
Make sure that there is nothing after the 'WHATEVER;'. Even a space will give a parse error.
I would delete the line and retype it, hitting <enter> immediately after typing the semi-colon.
make sure that EOT; is really at the begin of the line.
if ($muh="kuh") {
$foo = <<<EOT
some text text text
EOT;
}
What if you try:
$mystring = <<<'EOT'
...
EOT;
(Notice the single quotes around the first EOT)
I just copy/pasted that into a file and it ran without errors. (PHP 5.2.8 (cli) (built: Feb 6 2009 12:33:08))
So the problem is likely something near that code, but not something you included in the question.
Either that, or a change in PHP since your version was built.
You probably should check if you have any unclosed curly bracket (or brace, can't remember).
For example:
<?php
while(true) {
echo "Something\n";
?>
Will produce that error.
I don't have the rep for an uptic, but Ch4m3l3on and Pedro Cunhna are right... an incorrect heredoc probably won't cause that unexpected $end error, but an unclosed curly brace definitely would.