Duplicated content id uploading files with large filename - plone

I am trying to upload multiples files with collective.quickupload.
These are examples of filename:
'habana vedado casa edificio atlantic apartamento 11A (10).jpg'
'habana vedado casa edificio atlantic apartamento 11A (11).jpg'
'habana vedado casa edificio atlantic apartamento 11A (12).jpg'
This plugin generate the same id for each file.
It is using:
normalizer = component.getUtility(IIDNormalizer)
newid = '.'.join ((normalizer.normalize(filename), fileextension))
But with this code it generates the same id for each file.
How can I fix this?

Related

Tables in RMarkdown: not using dataframe and/or data.table

I'm having some issues trying to insert a table code in a text on RMarkdown.
Reading rmakdown cheat sheet (write with markdown) and following the instructions, my code is like this:
Palavra-chave
Biblioteca do Conhecimento Online]
Google acadêmico Portugal
Resultado encontrado
estilos de uso del espacio virtual
2
10
12
estilos de uso do espaço virtual
6
15
21
questionário estilos de uso do espaço virtual
1
5
6
Total
9
30
39
Unfortunately, in any rendering format (pdf, .docx, or HTML) table is not displayed right formatted...
Any thoughts?
Tks in advance!

Extract date from a text document in R

I am again here with an interesting problem.
I have a document like shown below:
"""UDAYA FILLING STATION ps\na MATTUPATTY ROAD oe\noe 4 MUNNAR Be:\nSeat 4 04865230318 Rat\nBree 4 ORIGINAL bepas e\n\noe: Han Die MC DE ER DC I se ek OO UO a Be ten\" % aot\n: ag 29-MAY-2019 14:02:23 [i\n— INVOICE NO: 292 hee fos\nae VEHICLE NO: NOT ENTERED Bea\nss NOZZLE NO : 1 ome\n- PRODUCT: PETROL ae\ne RATE : 75.01 INR/Ltr yee\n“| VOLUME: 1.33 Ltr ae\n~ 9 =6AMOUNT: 100.00 INR mae wae\nage, Ee pel Di EE I EE oe NE BE DO DC DE a De ee De ae Cate\notome S.1T. No : 27430268741C =. ver\nnes M.S.T. No: 27430268741V ae\n\nThank You! Visit Again\n""""
From the above document, I need to extract date highlighted in bold and Italics.
I tried with strpdate function but did not get the desired results.
Any help will be greatly appreciated.
Thanks in advance.
Assuming you only want to capture a single date, you may use sub here:
text <- "UDAYA FILLING STATION ps\na MATTUPATTY ROAD oe\noe 4 MUNNAR Be:\nSeat 4 04865230318 Rat\nBree 4 ORIGINAL bepas e\n\noe: Han Die MC DE ER DC I se ek OO UO a Be ten\" % aot\n: ag 29-MAY-2019 14:02:23 [i\n— INVOICE NO: 292 hee fos\nae VEHICLE NO: NOT ENTERED Bea\nss NOZZLE NO : 1 ome\n- PRODUCT: PETROL ae\ne RATE : 75.01 INR/Ltr yee\n“| VOLUME: 1.33 Ltr ae\n~ 9 =6AMOUNT: 100.00 INR mae wae\nage, Ee pel Di EE I EE oe NE BE DO DC DE a De ee De ae Cate\notome S.1T. No : 27430268741C =. ver\nnes M.S.T. No: 27430268741V ae\n\nThank You! Visit Again\n"
date <- sub("^.*\\b(\\d{2}-[A-Z]+-\\d{4})\\b.*", "\\1", text)
date
[1] "29-MAY-2019"
If you had the need to match multiple such dates in your text, then you may use regmatches along with regexec:
text <- "Hello World 29-MAY-2019 Goodbye World 01-JAN-2018"
regmatches(text,regexec("\\b(\\d{2}-[A-Z]+-\\d{4})\\b", text))[[1]]
[1] "29-MAY-2019" "29-MAY-2019"

Row count for a column

In my subreport I want do display for eg.
Number of clients born in 1972: 34
So in the database I have a list of their birth years
How can I display this number in a field?
Here is a Sample of the data:
<Born> <Name> <BleBle>
1981 Mnr EH Van Niekerk 9517
1982 MEV A BELL 9520
1972 Mnr GI van der Westhuize 9517
1987 Mnr A Juyn 9517
1983 Mev MJC Prinsloo 9513
1972 Mnr WA Van Rensburg 9517
1989 Kmdt EL Van Der Colff 9514
1972 Mnr JS Jansen Van Vuuren 9517
So if this was all the data the output would have to be
Number of clients born in 1972: 3
Create a variable BORN_IN_1972.
Set its "Variable class" to java.lang.Integer.
Set "Calculation" to "Count".
Set "Variable Expression" to $F{Born}.
Set "Initial Value Expression" to 0.
Than add "Summary" band to your report. And put static text "Number of clients born in 1972:" and text field "$V{BORN_IN_1972}" into it.
Assuming birth year is a string:
SELECT COUNT(*)
FROM MyClients
WHERE birth_year = '1972'
And if birth year is being used as an input control:
SELECT COUNT(*)
FROM MyClients
WHERE birth_year = $P{birth_year}
To count non-zero records in jasper use the expression below -
( $F{test} == 0.0 ? null : $F{test} )

want to change csv file date column format

Im newbie to batch/shell scripting. I have a CSV file like this:
Id depId Name city Date prod
12345 52845 ken LA 08.08.2013 16:06:53 KLS22
25685 28725 Larry MA 09.03.2013 16:06:58 KLt35
58345 28545 ken LA 06.08.2013 16:06:53 KLS22
75885 98725 Gow CA 05.04.2013 16:06:58 KLt35
about 2000 records. col are delimited by tab. I would like to change the date column to the format:
DD_MM_YYY_hh_mm_ss
I have tried something like this with awk:
awk -F '' '{ ("date -d \""$5"\" \"+%Y:%m/%d %T\"") | getline $5; print }' myfile.csv
but i get wrong output.
I expect output like this:
Id depId Name city Date prod
58345 28545 ken LA 03_06_2013_23_00_00 KLS22
75885 98725 Gow CA 05_06_2013_23_00_00 KLt35
Please help out! Thanks!!
One way with awk:
$ awk 'NR>1{gsub(/\./,"_",$5);gsub(/:/,"_",$6);$5=$5"_"$6;$6=$NF;NF--}{$1=$1}1' OFS="\t" myfile.csv
Test:
$ cat temp
Id depId Name city Date prod
12345 52845 ken LA 8.8.2013 16:06:53 KLS22
25685 28725 Larry MA 9.3.2013 16:06:58 KLt35
58345 28545 ken LA 6.8.2013 16:06:53 KLS22
75885 98725 Gow CA 5.4.2013 16:06:58 KLt35
$ awk 'NR>1{gsub(/\./,"_",$5);gsub(/:/,"_",$6);$5=$5"_"$6;$6=$NF;NF--}{$1=$1}1' OFS="\t" temp
Id depId Name city Date prod
12345 52845 ken LA 8_8_2013_16_06_53 KLS22
25685 28725 Larry MA 9_3_2013_16_06_58 KLt35
58345 28545 ken LA 6_8_2013_16_06_53 KLS22
75885 98725 Gow CA 5_4_2013_16_06_58 KLt35
A simpler approach which does not check if the string that looks like the date is really in the right columnt:
$ perl -pe 's/\t(\d)\.(\d)\.(\d\d\d\d) /sprintf("\t%04d-%02d-%02d ", $3, $2, $1) /e' t.csv
12345 52845 ken LA 2013-08-08 16:06:53 KLS22
25685 28725 Larry MA 2013-03-09 16:06:58 KLt35

Merging two files horizontally and formatting

I have two files as follows:
File_1
Austin
Los Angeles
York
San Ramon
File_2
Texas
California
New York
California
I want to merge them horizontally as follows:
Austin Texas
Los Angeles California
York New York
San Ramon California
I am able to merge horizontally by using paste command, but the formatting is going haywire.
Austin Texas
Los Angeles California
York New York
San Ramon California
I realize that paste is working as it is supposed to, but can someone point me in the right direction to get the formatting right.
Thanks.
paste is using a tab when 'merging' the file, so maybe you have to post-process the file and remove the tab with spaces:
paste File_1 File_2 | awk 'BEGIN { FS = "\t" } ; {printf("%-20s%s\n",$1,$2) }'
result:
Austin Texas
Los Angeles California
York New York
San Ramon California
Firstly you have to check number of characters in the longest line. Than you may use fmt to pad line from the first file to greater length. Finish it using paste.
If you have an idea about the field width, you could do something like this:
IFS_BAK="$IFS"
IFS=$'\t'
paste file_1 file_2 \
| while read city state; do
printf "%-15s %-15s\n" "$city" "$state"
done
IFS="$IFS_BAK"
Or this shorter version:
paste file_1 file_2 | while IFS=$'\t' read city state; do
printf "%-15s %-15s\n" "$city" "$state"
done
Or use the column tool from bsdmainutils:
paste file_1 file_2 | column -s $'\t' -t

Resources