We will be migrating from Ask to Discourse on the first week of August, read the details here

# Total # lines in .txt file

Is there a function ( macro ) that returns the number of lines in text file ?
Macro is in Libre draw.

If not, any eloquent recommendations to find total number lines in text file?

edit retag close merge delete

Depending on which operating system you use, why not open the .txt document in Notepad++ or NotepadQQ, each of which will display line numbers and give you the total number of lines in the document.

( 2021-04-26 01:39:21 +0200 )edit

Yes, that would provide line numbers, but I would prefer not to have to manually input into macro in this case; rather have the macro check total lines itself automatically, rather then interrupting the macro's sub-routine.

( 2021-04-26 02:02:03 +0200 )edit
1

You say you are using a .txt file and your question is tagged Draw. How are you using Draw with .txt files?

( 2021-04-26 03:37:22 +0200 )edit

Then when you write "# lines", what you actually mean? are you talking about a line as any amount of text between two line breaks (various depending on TXT kind: Linux/macOS line ends differ from Windows line ends), which usually would translate into paragraph count (but would also be more complex if import is not configured correctly to consider proper kind of line ends, or if the file includes several kinds of line ends), or the lines that result from laying out (and wrapping) that text in some component of LibreOffice (e.g., in a text box in Draw)?

Maybe your macro wants to read a text file itself (e.g., using "com.sun.star.ucb.SimpleFileAccess" and "com.sun.star.io.TextInputStream" services), and so is in fact not specific to used component?

( 2021-04-26 10:19:42 +0200 )edit

"How are you using Draw with .txt files ? "

Macro to read .txt file, and then output desired data (strings/text/etc) to multiple draw pages via textbox(es).

( 2021-04-26 15:36:10 +0200 )edit

See answer by @regina to this question for an example of the code to read a text file line by line.

( 2021-04-26 16:49:11 +0200 )edit

Sort by » oldest newest most voted

In a decent command line shell enter wc -l filename.txt

more

Seems it's possible with a no so decent command line link text like type *.EXT | find /c /v "" :)