Change "Continued on next page" in df.to_latex / PYLATEX - python-3.x

Good afternoon. I would like to change the phrase "Continued on next page" from df.to_latex.
when running
import pylatex to pl
pl.NoEscape(dff1.to_latex(longtable=True, index=False, multicolumn=True, multirow=True,caption='Tabla de anexos'))
turns out this
\begin{longtable}{lrrrrrr}
\caption{Puntos criticos expuestos a peligro}\\
\toprule
{} & \multicolumn{3}{l}{ANA} & \multicolumn{3}{l}{INGEMMET} \\
{} & Nivel 2 & Nivel 3 & Nivel 4 & Nivel 2 & Nivel 3 & Nivel 4 \\
\midrule
\endfirsthead
\caption[]{Puntos criticos expuestos a peligro} \\
\toprule
{} & \multicolumn{3}{l}{ANA} & \multicolumn{3}{l}{INGEMMET} \\
{} & Nivel 2 & Nivel 3 & Nivel 4 & Nivel 2 & Nivel 3 & Nivel 4 \\
\midrule
\endhead
\midrule
\multicolumn{7}{r}{{Continued on next page}} \\
\midrule
\endfoot
\bottomrule
\endlastfoot
Ancash & 13 & 0 & 0 & 113 & 0 & 0 \\
Apurimac & 9 & 0 & 0 & 39 & 0 & 0 \\
Arequipa & 2 & 0 & 0 & 13 & 0 & 0 \\
Ayacucho & 34 & 0 & 0 & 28 & 0 & 0 \\
Cusco & 59 & 0 & 0 & 68 & 0 & 0 \\
Huancavelica & 43 & 0 & 0 & 60 & 0 & 0 \\
Hutnuco & 13 & 0 & 0 & 0 & 0 & 0 \\
Junin & 16 & 0 & 0 & 0 & 0 & 0 \\
Pasco & 17 & 0 & 0 & 23 & 0 & 0 \\
Puno & 7 & 0 & 0 & 2 & 0 & 0 \\
Huanuco & 0 & 0 & 0 & 32 & 0 & 0 \\
Junmn & 0 & 0 & 0 & 41 & 0 & 0 \\
Lima & 0 & 0 & 0 & 61 & 0 & 0 \\
\end{longtable}
and what I'm looking for is that \multicolumn{7}{r}{{Continued on next page}} \ be changed by \multicolumn{7}{r}{{Siguiente pagina}} \
try pl.NoEscape(df_zc_ana_ingmmet.to_latex(longtable=True,index=True,multicolumn=True,multirow=True, caption='Puntos criticos expuestos a peligro',multicolumn_format='{7}{r}{{Continua en la siguiente pagina}}')) but i didn't succeed

Related

What might cause "commitAndReleaseBuffer: invalid argument (invalid character)" when using pandoc as a library?

I'm using pandoc as a library, and the relevant code snippet is:
module Lib
( latexDirToTex, latexToTxt
) where
import qualified Data.ByteString as BS
import Data.List (isSuffixOf)
import qualified Data.Text as T
import qualified Data.Text.IO as TIO
import ForeignLib (chdir)
import Path
import System.Directory (getDirectoryContents )
import Text.Pandoc
import Text.Pandoc.UTF8 (toText)
latexToTxt :: Path b File -> IO T.Text
latexToTxt fPath = do
fileBS <- BS.readFile $ toFilePath fPath
result <- runIO $ do
doc <- readLaTeX def $ toText fileBS
writePlain def doc
handleError result
From this, you can see that I'm basically just calling readLaTeX to read in a LaTeX document.
However, when I try to run this code, I have lots of trouble in practice, with errors like the one in the title:
[WARNING] Could not convert TeX math '\begin{array}{ccccccccccc}
& & 1 & 2 & 4 & 7 & 11 & 15 & 15 & & \\
\hline
0 & \vline & 1 & 0 & 0 & 0 & 0 & 0 & 0 & \vline & 1 \\
1 & \vline & 1 & 1 & 0 & 0 & 0 & 0 & 0 & \vline & 3 \\
2 & \vline & 1 & 2 & 1 & 0 & 0 & 0 & 0 & \vline & 9 \\
3 & \vline & 1 & 3 & 3 & 1 & 0 & 0 & 0 & \vline & 26 \\
4 & \vline & 1 & 4 & 6 & 4 & 1 & 0 & 0 & \vline & 72 \\
5 & \vline & 1 & 5 & 10 & 10 & 5 & 1 & 0 & \vline & 191 \\
6 & \vline & 0 & 6 & 15 & 20 & 15 & 6 & 1 & \vline & 482 \\
7 & \vline & 0 & 0 & 21 & 35 & 35 & 21 & 7 & \vline & 1134 \\
8 & \vline & 0 & 0 & 0 & 56 & 70 & 56 & 28 & \vline & 2422 \\
9 & \vline & 0 & 0 & 0 & 0 & 126 & 126 & 34 & \vline & 4536 \\
10 & \vline & 0 & 0 & 0 & 0 & 0 & 252 & 210 & \vline & 6930 \\
11 & \vline & 0 & 0 & 0 & 0 & 0 & 0 & 462 & \vline & 6930
\end{array}', rendering as TeX:
0 & \vline & 1 & 0 & 0 & 0 & 0 & 0 &
^
unexpected "\\"
expecting "&", "\\\\", white space or "\\end"
arxiv-pandoc-static: <stdout>: commitAndReleaseBuffer: invalid argument (invalid character)
Contrasting this to using the pandoc executable directly, no such errors occur and I receive quite good output. I'd like to configure the pandoc readers to be as flexible as possible and to not bail out on errors (or better yet, avoid the errors in the first place). How can I achieve this through the pandoc API?
I believe that this is less of a pandoc issue and more one of a GHC or the text package. The answer can be found in a completely unrelated Haskell project, the hledger docs:
Getting errors like "Illegal byte sequence" or "Invalid or
incomplete multibyte or wide character" or "commitAndReleaseBuffer:
invalid argument (invalid character)"
Programs compiled with GHC (hledger, haskell build tools, etc.) need to
have a UTF-8-aware locale configured in the environment, otherwise they
will fail with these kinds of errors when they encounter non-ascii
characters.
To fix it, set the LANG environment variable to some locale which
supports UTF-8. The locale you choose must be installed on your system.
So running something like export LANG=C.UTF-8 in your shell should resolve this.

VBA Set Multiple Filters

I've used filters manually, but never with VBA.
I have the following:
K2 - Item 1
L2 - Item 2
M2 - Item 3
N2 - Item 4
O2 - Item 5
P2 - Item 6
Q2 - Item 7
R2 - Item 8
S2 - Item 9
T2 - Item 10
then underneath each user with their Item. Some may have multiple items (i.e. P, R, S & T).
I want to create a "Drop down" (Which I can do haha) where it'll have the 10 Items in it, and when you select an Item, it sets all the filters to blank, but the one Item it, that's been selected, is the only one showing.
Currently doing it manually, but doing it for 10 different items is becoming a head ache!
Just looking to see if someone can point me in the right direction before I spiral down the rabbit hole?
Cheers
Edit:
Have started to try this code, and it does work, but takes forever to process (Downside of having 20k+ lines of data to sift through!)
Sub FilterMasks(mask As String)
Dim LastRow, RunningNum
LastRow = Sheets("Output").Range("A" & Rows.Count).End(xlUp).Row + 1
For RunningNum = 3 To LastRow
Sheets("Output").Rows(RunningNum).EntireRow.Hidden = False
If mask = "Type" Then
If Application.WorksheetFunction.CountA(Range("K" & RunningNum & ":T" & RunningNum)) > 0 Then
Sheets("Output").Rows(RunningNum).EntireRow.Hidden = True
End If
End If
If mask Like "Item 1" Then
If Application.WorksheetFunction.CountA(Range("J" & RunningNum)) = 1 Or Application.WorksheetFunction.CountA(Range("L" & RunningNum & ":T" & RunningNum)) > 0 Then
Sheets("Output").Rows(RunningNum).EntireRow.Hidden = True
End If
End If
If mask Like "Item 2" Then
If Application.WorksheetFunction.CountA(Range("J" & RunningNum & ":K" & RunningNum)) > 0 Or Application.WorksheetFunction.CountA(Range("M" & RunningNum & ":T" & RunningNum)) > 0 Then
Sheets("Output").Rows(RunningNum).EntireRow.Hidden = True
End If
End If
If mask Like "Item 3" Then
If Application.WorksheetFunction.CountA(Range("J" & RunningNum & ":L" & RunningNum)) > 0 Or Application.WorksheetFunction.CountA(Range("N" & RunningNum & ":T" & RunningNum)) > 0 Then
Sheets("Output").Rows(RunningNum).EntireRow.Hidden = True
End If
End If
If mask Like "Item 4" Then
If Application.WorksheetFunction.CountA(Range("J" & RunningNum & ":M" & RunningNum)) > 0 Or Application.WorksheetFunction.CountA(Range("O" & RunningNum & ":T" & RunningNum)) > 0 Then
Sheets("Output").Rows(RunningNum).EntireRow.Hidden = True
End If
End If
If mask Like "Item 5" Then
If Application.WorksheetFunction.CountA(Range("J" & RunningNum & ":N" & RunningNum)) > 0 Or Application.WorksheetFunction.CountA(Range("P" & RunningNum & ":T" & RunningNum)) > 0 Then
Sheets("Output").Rows(RunningNum).EntireRow.Hidden = True
End If
End If
If mask Like "Item 6" Then
If Application.WorksheetFunction.CountA(Range("J" & RunningNum & ":O" & RunningNum)) > 0 Or Application.WorksheetFunction.CountA(Range("Q" & RunningNum & ":T" & RunningNum)) > 0 Then
Sheets("Output").Rows(RunningNum).EntireRow.Hidden = True
End If
End If
If mask Like "item 7" Then
If Application.WorksheetFunction.CountA(Range("J" & RunningNum & ":P" & RunningNum)) > 0 Or Application.WorksheetFunction.CountA(Range("R" & RunningNum & ":T" & RunningNum)) > 0 Then
Sheets("Output").Rows(RunningNum).EntireRow.Hidden = True
End If
End If
If mask Like "Item 8" Then
If Application.WorksheetFunction.CountA(Range("J" & RunningNum & ":Q" & RunningNum)) > 0 Or Application.WorksheetFunction.CountA(Range("S" & RunningNum & ":T" & RunningNum)) > 0 Then
Sheets("Output").Rows(RunningNum).EntireRow.Hidden = True
End If
End If
If mask Like "Item 9" Then
If Application.WorksheetFunction.CountA(Range("J" & RunningNum & ":R" & RunningNum)) > 0 Or Application.WorksheetFunction.CountA(Range("T" & RunningNum)) > 0 Then
Sheets("Output").Rows(RunningNum).EntireRow.Hidden = True
End If
End If
If mask Like "Item 10" Then
If Application.WorksheetFunction.CountA(Range("J" & RunningNum & ":S" & RunningNum)) > 0 Then
Sheets("Output").Rows(RunningNum).EntireRow.Hidden = True
End If
End If
Next
End Sub````
But I have Filters on all the Headers, was wondering if it'd be smarter to use the Filters rather than the above code!
If so, where would I look at to play around with filters?

Excel multiple V look up formula pasted to used range by VBA

I need to summarise data from sheet5 into sheet9.
Sheet 5 has multiple rows of data with yearly and monthly data.
Sheet 9 has a list of ID's and Company names. No duplicates.
The matching ID is in column A of both sheets.
I need to summarise the data in sheet5 , by year , month and if there is any data added in sheet5 columns CS:DD.
I wanted to run a VBA code , that ask for year with an input box. Then based on that year. example if year was 2018
Match Column A sheet9 to Column A Sheet5
If Column D sheet5 = 2018 and Column E sheet5 = M1 and sheet5.Range("CS:DD") contains atleast 1 non blank cell. Then in column D on sheet5. Add yes. Else No. Column D would be for Jan (M1) Month 1.
Then same formula pasted in Column E based on if Column E = M2 , this would be for Feb , replicate this up to Dec.
I have first of all tried searching multiple VBLook Up formulas , but could not find a solution
Sub Progress()
Dim x
Dim y
Dim tabl As ListObject
Set tabl = Sheet5.ListObjects(1)
Dim orgid As String
Dim yearchoice As Variant
yearchoice = InputBox("Enter year to filter by format is 2019", "Select Year")
Dim lrow1, lrow6
tabl.AutoFilter.ShowAllData
tabl.Range.AutoFilter Field:=4, Criteria1:=yearchoice
lrow1 = Sheet5.Cells(Rows.Count, 1).End(xlUp).Row
lrow6 = Sheet6.Cells(Rows.Count, 1).End(xlUp).Row
For x = 2 To lrow6
orgid = Sheet6.Range("A" & x).Value
For y = 2 To lrow1
If Sheet5.Range("A" & y).Value = orgid And Sheet5.Range("E" & x).Value = "M1" And WorksheetFunction.CountA(Sheet5.Range("CS" & y & ":DD" & y).Value) > 0 Then Sheet6.Range("D" & x).Value = "YES": GoTo found
If Sheet5.Range("A" & y).Value = orgid And Sheet5.Range("E" & x).Value = "M2" And WorksheetFunction.CountA(Sheet5.Range("CS" & y & ":DD" & y).Value) > 0 Then Sheet6.Range("E" & x).Value = "YES": GoTo found
If Sheet5.Range("A" & y).Value = orgid And Sheet5.Range("E" & x).Value = "M3" And WorksheetFunction.CountA(Sheet5.Range("CS" & y & ":DD" & y).Value) > 0 Then Sheet6.Range("F" & x).Value = "YES": GoTo found
If Sheet5.Range("A" & y).Value = orgid And Sheet5.Range("E" & x).Value = "M4" And WorksheetFunction.CountA(Sheet5.Range("CS" & y & ":DD" & y).Value) > 0 Then Sheet6.Range("G" & x).Value = "YES": GoTo found
If Sheet5.Range("A" & y).Value = orgid And Sheet5.Range("E" & x).Value = "M5" And WorksheetFunction.CountA(Sheet5.Range("CS" & y & ":DD" & y).Value) > 0 Then Sheet6.Range("H" & x).Value = "YES": GoTo found
If Sheet5.Range("A" & y).Value = orgid And Sheet5.Range("E" & x).Value = "M6" And WorksheetFunction.CountA(Sheet5.Range("CS" & y & ":DD" & y).Value) > 0 Then Sheet6.Range("I" & x).Value = "YES": GoTo found
If Sheet5.Range("A" & y).Value = orgid And Sheet5.Range("E" & x).Value = "M7" And WorksheetFunction.CountA(Sheet5.Range("CS" & y & ":DD" & y).Value) > 0 Then Sheet6.Range("J" & x).Value = "YES": GoTo found
If Sheet5.Range("A" & y).Value = orgid And Sheet5.Range("E" & x).Value = "M8" And WorksheetFunction.CountA(Sheet5.Range("CS" & y & ":DD" & y).Value) > 0 Then Sheet6.Range("K" & x).Value = "YES": GoTo found
If Sheet5.Range("A" & y).Value = orgid And Sheet5.Range("E" & x).Value = "M9" And WorksheetFunction.CountA(Sheet5.Range("CS" & y & ":DD" & y).Value) > 0 Then Sheet6.Range("L" & x).Value = "YES": GoTo found
If Sheet5.Range("A" & y).Value = orgid And Sheet5.Range("E" & x).Value = "M10" And WorksheetFunction.CountA(Sheet5.Range("CS" & y & ":DD" & y).Value) > 0 Then Sheet6.Range("M" & x).Value = "YES": GoTo found
If Sheet5.Range("A" & y).Value = orgid And Sheet5.Range("E" & x).Value = "M11" And WorksheetFunction.CountA(Sheet5.Range("CS" & y & ":DD" & y).Value) > 0 Then Sheet6.Range("N" & x).Value = "YES": GoTo found
If Sheet5.Range("A" & y).Value = orgid And Sheet5.Range("E" & x).Value = "M12" And WorksheetFunction.CountA(Sheet5.Range("CS" & y & ":DD" & y).Value) > 0 Then Sheet6.Range("O" & x).Value = "YES": GoTo found
found:
Next y
Next x
End Sub
This code froze on me , I was told a formula pasted in would be quicker

Why do I get Error 2042 in VBA Evaluate INDEX/MATCH?

I asked for advice everywhere but with no help so far!
= Evaluate("INDEX(TEMPDB!E" & lrCHIIMPORT2 + 1 & ":E" & lr3CHIMPORT2 & ",
MATCH(STATIONS!B" & RARTSTAT3 & "& STATIONS!" & matchARTIST & "1, TEMPDB!C" &
lrCHIIMPORT2 + 1 & ":C" & lr3CHIMPORT2 & " & TEMPDB!A" & lrCHIIMPORT2 + 1 &
":A" & lr3CHIMPORT2 & "))")
I get
Error 2042
Both criteria is STRING, output is INTEGER or STRING!
Sheets("STATIONS").Evaluate("INDEX(TEMPDB!E" & lrCHIIMPORT2 + 1 & ":E" &
lr3CHIMPORT2 & ", MATCH(STATIONS!B" & RARTSTAT3 & "& STATIONS!" & matchARTIST
& "1, TEMPDB!C" & lrCHIIMPORT2 + 1 & ":C" & lr3CHIMPORT2 & " & TEMPDB!A" &
lrCHIIMPORT2 + 1 & ":A" & lr3CHIMPORT2 & ",0))")
i can't believe... Just FALSE on the end...!

Excel convert column into row

I want to convert Column data into 4 rows in excel.
I have data like this
A B C D
1
2
.
.
20000
ABCD are columns, only A has value till 1 to 20000.
I want to equally divide 4 values ABCD(1234), ABCD (5678)
How i can do in excel ?
You can use the following formula:
=IFERROR(INDEX($A:$A,ROW(A1)*4-4+COLUMN(A1)),"")
drag it in the same row 3 times and down
1 2 3 4 Drag in the same row 3 columns
5 6 7 8 and down in each column
9 10 11 12
13 14 15 16
17 18 19 20
21 22 23 24
25 26 27 28
29 30 31 32
33 34 35 36
Like this?
Sub divideby4()
Dim i As Integer
For i = 1 To 5
Range("D" & i).Value = Range("A" & i).Value / 4
Range("C" & i).Value = Range("A" & i).Value / 4
Range("B" & i).Value = Range("A" & i).Value / 4
Range("A" & i).Value = Range("A" & i).Value / 4
Next i
End Sub
Before and after:
Alternatively:
Sub equallydivideby4()
Dim i As Integer, j As Integer
j = 1
For i = 1 To 10
Range("D" & i).Value = Range("A" & j + 3).Value
Range("C" & i).Value = Range("A" & j + 2).Value
Range("B" & i).Value = Range("A" & j + 1).Value
Range("A" & i).Value = Range("A" & j).Value
j = j + 4
Next i
End Sub
Produces (Before/After):

Resources