Import from file having line breaks [closed] - import

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
How to import data from a export file having the line breaks in a column.
for example i have a table with column as remarks, when the user entered the remarks from frontend of application it allowed the line breaks and the same data is stored in the table. but when export is taken and tried to import to other table the import failed due to line breaks.

Assuming you're using the IMPORT or LOAD utilities to load data into DB2 for Linux, UNIX and Windows:
If your character fields are properly quoted (i.e. they have " at the beginning and end of each character field in the file), then you can use the DELPRIORITYCHAR file-type modifier:
import from yourfile.csv
of del modified by delprioritychar
insert into yourtable
This instructs the IMPORT and LOAD utilities to prioritize the character delimiter (") over the record delimiter (i.e. newline).

I think the easiest approach would be to replace the line break characters with something else, e.g. the escape sequences \n, then, if needed, replace them back after importing.

Related

Rust Command Line Arguments [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
The community is reviewing whether to reopen this question as of 2 years ago.
Improve this question
I'm experimenting with command line arguments in Rust.
Windows Power Shell.
if let Some(a) = env::args().nth(1) {
println!("parâmetro é {:?}", &a);
} else ...
ARG = "Qu'il" prints "parâmetro é Qu\'il" (ok)
ARG = Qu'il (results in apparent infinite loop)
ARG = Qu\il (idem)
So, what's the proper way to handle this (the error)?
Thanks in advance.
I can't really discern what error you are referring to, so I'll explain the reasoning for the behavior you are seeing:
You are using the format specifier {:?} which makes Rust print the string in a debug-friendly manner. If you use println!("parâmetro é {}", &a); instead you'd see parâmetro é Qu'il
This is not an infinite loop. Apostrophes (') are special characters in PowerShell to define a literal string. The reason why nothing is happening is that PowerShell is waiting for you to write the rest of the string and finish with another apostrophe.
Like nr. 1
See more here:
About literal strings in PowerShell
Can I use a single quote in a PowerShell 'string'?

append previous line with current line if the file contains blanks [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to append lines to the previous line if the blank line is followed by the line.
For example:
A
B
C
1
D
E
B
Ouput:
A
B
C
1D
EB
See also Håkon Hægland's comment above. This is one of those problems that lends itself to treating the whole file as one long string (with embedded newline characters). Perl has a flag -0 for changing or turning off the default "record separator" definition that accomplishes this. Then you just need to realize that, depending on your definition of "blank line", you seem to be requesting that all sequences of two or more newline characters in a row simply be removed. (If your definition of "blank line" can include lines with blank characters on them (whitespace, i.e. spaces and tabs), you'll need a more complicated expression.) This compact one-liner will do it:
$ perl -0pe 's/\n\n+//g' blanklines
A
B
C
1D
EB
Now please tell me this was not a homework assignment.
Update: I realized a couple of additional things. 1) Since newline is included in Perl's whitespace special escape \s, expanding to handle the case of blank lines having blank characters on them is not really more complex: perl -0pe 's/\n\s+//g' blanklines. 2) There is an edge case that this solution doesn't handle right: blank lines at the end of the input. I'll leave that as a problem for the student. :-)

How does compiler understand Unicode characters so quickly? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have made a document based program lately.
But what intrigues me that how can a compiler(in my case, objective-c) convert any character into Unicode so fast while these characters are only visual presentations.
I think maybe A~Z and all other common characters can be converted from ASCII to Unicode very easily. What about other special character such as brand icon and copyright icon?
I am solely interested in the internal working of such conversion.
Example:
How do compiler understand what "©" is in a blink of second? Is it by looking up a UNICODE table? But if I have 1000000 "©", does my compiler look them up in the table 1000000 times? That is very time consuming, isn't it?
The compiler doesn't see "©". It sees whatever numerical representation of "©" occurs in the source file it's processing. No lookup is needed, because it's already in the form the compiler uses. (Some conversions might be needed if, for example, the source file is in UTF-8 and the compiler uses UTF-32 internally, but such conversions don't require a full Unicode table.)

How to convert character to unicode? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have this character.
&#8211
How to convert this character to unicode?
Sorry if it is a silly question.
It's not a silly question, character encoding can be tricky to get your head around. I highly recommend reading The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) (I'm sure you can guess the topic).
Unicode itself isn't an encoding, it's a very long list of characters and code points. What I'm guessing you want to do is display the dash character in some way. Where are you wanting to display or store the data? If it's in a browser, then that representation should work as that's the HTML encoded version. If you want to store it in a database then you'll need to convert that encoded version to a string and then convert that string to whatever encoding the database is using.
Take a look at this source has the encoding in different formats
http://www.fileformat.info/info/unicode/char/2013/index.htm
but each language has its own rules on how to write this in a string/char literal

Write a limited number of characters then return to the line in Perl and do not cut the last word [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a character string in an array and I want to write it to a file. The problem is I need to write for a number of characters limited to 100 then I must return to the the line and finish the content of the sentence. Then if I happen to 100 characters again I return to the line until I finish my chain content in the table.
The Text::Wrap module is likely to do what you want, and is a part of core Perl meaning you don't have to install it.
This program reads the text from the DATA pseudo-handle and reformats it.
use strict;
use warnings;
use Text::Wrap;
my #text = <DATA>;
chomp #text;
$Text::Wrap::columns = 100;
print Text::Wrap::wrap '', '', #text;
__DATA__
"Text::Wrap::wrap()" is a very simple paragraph formatter. It formats a
single paragraph at a time by breaking lines at word boundaries.
Indentation is controlled for the first line ($initial_tab) and all
subsequent lines ($subsequent_tab) independently. Please note:
$initial_tab and $subsequent_tab are the literal strings that will be
used: it is unlikely you would want to pass in a number.
Text::Wrap::fill() is a simple multi-paragraph formatter. It formats
each paragraph separately and then joins them together when it's done.
It will destroy any whitespace in the original text. It breaks text into
paragraphs by looking for whitespace after a newline. In other respects
it acts like wrap().
Both "wrap()" and "fill()" return a single string.
output
"Text::Wrap::wrap()" is a very simple paragraph formatter. It formats a single paragraph at a time
by breaking lines at word boundaries. Indentation is controlled for the first line ($initial_tab)
and all subsequent lines ($subsequent_tab) independently. Please note: $initial_tab and
$subsequent_tab are the literal strings that will be used: it is unlikely you would want to pass in
a number. Text::Wrap::fill() is a simple multi-paragraph formatter. It formats each paragraph
separately and then joins them together when it's done. It will destroy any whitespace in the
original text. It breaks text into paragraphs by looking for whitespace after a newline. In other
respects it acts like wrap(). Both "wrap()" and "fill()" return a single string.
I think you're looking for something like Text::Reform or Text::Autoformat.