I would like to reformat the content of the text file using Scala such as for the given sample file:
"good service"
Tom Martin (USA) 17th October 2015
4
Hi my name is
Tom.
I love boardgames.
Aircraft TXT-102
"not bad"
M Muller (Canada) 22nd September 2015
6
Hi
I
like
boardgames.
Aircraft TXT-101
Type Of Customer Couple Leisure
Cabin Flown FirstClass
Route IND to CHI
Date Flown September 2015
Seat Comfort 12345
Cabin Staff Service 12345
.
.
Gets reformated to this:
"good service"
Tom Martin (USA) 17th October 2015
4
Hi my name is Tom. I love boardgames.
Aircraft TXT-102
"not bad"
M Muller (Canada) 22nd September 2015
6
Hi I like boardgames.
Aircraft TXT-101
Type Of Customer Couple Leisure
Cabin Flown FirstClass
Route IND to CHI
Date Flown September 2015
Seat Comfort 12345
Cabin Staff Service 12345
.
.
I have identified the pattern of my file, which is: This multi-line string comes between a digit and word separated by tabs.
For example, first block's multi line content comes between 4 and Aircraft TXT-102. Second block's multi line content comes between 6 and Aircraft TXT-101 Also, blocks are delimited by two new lines.
I know of Pattern matching using regex can help but I do not know how to handle this on file.
What I'd do, in pseudocode:
while more lines available {
lines_so_far = read input until a number is seen
output(lines_so_far)
lines_to_join = read input until "Aircraft" is seen
output(joined lines_to_join)
}
A regexp for a line consisting of only a number is ^\d+$; for a line starting with "Airline", ^Airline .*. The convenience method to look at is takeWhile.
Related
I have a CSV file source that has a field containing "CR" and "LF" type escape characters.
I'm trying to use a DataFlow and Derived Column to remove the unwanted characters but its not exactly working.
Here is my input with the unwanted escape chars
I'm using this expression against the synopsis column:
regexReplace(regexReplace(synopsis, `[\n]`, ''),`[\r]`, '')
As suggested in this similar post - How to replace CR and LF in Data Factory expressions
But I'm still getting some LF chars, but also a lot of extra commas.
Here is my output still with LF and extra Commas
Original in text format:
"TTL-100912","False",,"Bad Guys, The","GEN-ANI",,"Nobody has ever failed so hard at trying to be good as The Bad Guys.
In the new action comedy from DreamWorks Animation, based on the New York Times best-selling book series, a crackerjack criminal crew of animal outlaws are about to attempt their most challenging con yet--becoming model citizens.
Never have there been five friends as infamous as The Bad Guys--dashing pickpocket Mr. Wolf (Academy Award® winner Sam Rockwell, Three Billboards Outside Ebbing, Missouri), seen-it-all safecracker Mr. Snake (Marc Maron, GLOW), chill master-of-disguise Mr. Shark (Craig Robinson, Hot Tub Time Machine franchise), short-fused "muscle" Mr. Piranha (Anthony Ramos, In the Heights) and sharp-tongued expert hacker Ms. Tarantula (Awkwafina, Crazy Rich Asians), aka "Webs." The film co-stars Zazie Beetz (Joker), Lilly Singh (Bad Moms) and Emmy winner Alex Borstein (The Marvelous Mrs. Maisel).
Based on the blockbuster Scholastic book series by Aaron Blabey, THE BAD GUYS is directed by Pierre Perifel (animator, the Kung Fu Panda films), making his feature-directing debut. The film is produced by Damon Ross (development executive Trolls, The Boss Baby, co-producer Nacho Libre) and Rebecca Huntley (associate producer, The Boss Baby). The executive producers are Aaron Blabey, Etan Cohen and Patrick Hughes. ",,"BAD GUYS, THE","Bad Guys, The",,,,"2021-10-12 15:39:24",,
The way the source file was being produced was my complicating factor.
I changed the Row Delimiter in the production of my source csv to "¬" from "," and then was able to use this expression in a data flow to clean the contents of the Synopsis field:
regexReplace(synopsis, ',|[\n]|[\r]', ' ')
I want to print check from SAP Business one. I do all setting except the bank check Date have issue. in bank check the date is in boxes and having spacing.
can any one help me to how can i do it?
as Siva reccomended (or similar) ---
8 separate formulas
left(totext(Currentdate,'dd'),1) //d1
right(totext(Currentdate,'dd'),1) //d2
left(totext(Currentdate,'MM'),1) //m1
right(totext(Currentdate,'MM'),1) //m2
left(totext(Currentdate,'yyyy'),1) //y1
mid(totext(Currentdate,'yyyy'),2,1) //y2
mid(totext(Currentdate,'yyyy'),3,1) //y3
mid(totext(Currentdate,'yyyy'),4,1) //y4
Place in report and format each to have top, bottom, left and right borders.
take as mnay formulas as many characters in date and in each formula take one date character and display all formulas side by side.
you can extract single chracters ny conveting date to strings.
after placing all formulas side by side, Apply borders for those formulas.
For PLD in SAP Business One use the following formula
F_108==>
Document Date
F_195==>
Substring(Concat("0",Day(F_108)),Length(Concat("0",Day(F_108)))-2,Length(Concat("0",Day(F_108)))) --> Day 2 result is 02 & for day 28 result is 28
Substring(F_195,0,1) -->Extract the left digit & used to display in cheque i.e 0 or 2 from the above example
Substring(F_195,1,2) -->Extract the right digit & used to display in cheque i.e 2 or 8 from the above example
Do the same for month by replacing the Day() with Month()
Thanks
I have a date field in a form
xtype: 'datefield',
id: 'dateId',
maskRe: /[0-9\/]/,
format : 'm/d/Y',
for ex - if the date populated in that field is 07/30/2014. now i want to manually edit the date, if i give two backspaces, which means 07/30/20. and then click some where in the form, the year is getting defaulted to 07/30/2020. how to stop this getting defaulted to that 2020 year.
I answered this in my comment, but I will try to expand on that comment as much as possible, and make it as clear as possible. Here is the original comment:
"07/30/20 is equivalent to 07/30/2020. This is expected and normal behavior. When a year is only two digits, it is always the last two digits, so 20 == 2020, 00 == 2000, 14 == 2014, etc."
So, let me step you through an example.
You type 08/08/2014 into the datefield.
Hit backspace twice, removing the 1 and the 4.
Now you have 08/08/20.
When writing dates, the year can be written as 2 digits or 4. If written as two, the last two digits are used. So, the year 20 is the same as the year 2020.
The datefield has logic to handle 2 digit dates, so it knows that 08/08/20 is actually 08/08/2020.
That is why when you have 08/08/20 in a datefield, it interprets it as 08/08/2020.
I am using ckeditor to compose the emails, I am using the html generated by it to send the html emails ad i also need the text version also, So having both html and plain text version in emails will avoid the spam.
What is the way to get the text from ckeditor html code in java.
This is quite simple JavaScript call:
CKEDITOR.instances.yourEditorInstance.getData()
Returns:
<h1>Apollo 11</h1>
<p><b>Apollo 11</b> was the spaceflight that landed the first humans, Americans Neil Armstrong and Buzz Aldrin, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.</p>
However:
CKEDITOR.instances.yourEditorInstance.editable().getText()
Returns:
Apollo 11
Apollo 11 was the spaceflight that landed the first humans, Americans Neil Armstrong and Buzz Aldrin, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.
I'm successfully setting a date-picker with an initial date from a plist, but I see some unwanted blue values in the month, day, and year components, presumably corresponding to current date. So if today is April 18, 2010 and initial date being set is March 19, 2008, it looks like this (bold represents the blue):
January 17 2006
February 18 2007
------------------------------
March 19 2008
------------------------------
April 20 2009
May 21 2010
First question is: How do I get rid of the blue?
And second question: Ideally, how do I get it to look like this?
January 17 2006
February 18 2007
------------------------------
March 19 2008
------------------------------
April 20 2009
May 21 2010
Third question, totally unrelated and not as important: How could I have gotten the above to show in blue rather than bold? I see blue in code snippets all the time.
Matt
Sadly, I do not believe it's possible to suppress the coloring of the current date components in blue. You could always file a feature request for this functionality.
As a last resort, you could implement your own (or Google for "generic date picker" - someone has already done this).
I think the code sample formatter automagically makes things blue that it thinks are keywords, like:
UIDatePicker* myPicker;
I didn't tell it to make that blue, it just is.