Re: Line Pop Hack - .txt

0 views
Skip to first unread message
Message has been deleted

Anastacia Iacono

unread,
Jul 7, 2024, 3:18:06 PM7/7/24
to ramipercoa

I tried working with loops for extracting the content in form of lists, but I dont know how to store the actual results from the loop into different lists. I'm currently using the open() function to work with the files, but can't figure how to achieve this.

Line pop hack - .txt


Download https://ckonti.com/2yLDm4



If we imagine you have a lot of lines to take. You can use a loop to get all the lines step by step(You can get all lines as an array and then get them in loop or take one line in every step - I'm letting you to find this functions) and in every step you can use another loop inside of it and take the strings. To do that you should use split for every line and get array of strings belongs that line. Split functions takes a string as a parameter and returns you an array that includes all that strings. You can check it.

But in your situation you want to create new array for every line in your example for 2 lines, you can take first line from file and split it and after that you can do this for other too. So you will get to 2 array includes lines.

But if you wonder how can i do this for uncertain number of line, you can use the first method that I mentioned and add all line arrays to an array at the end of every step in your first(inclusive) loop . So you will have all arrays that includes all line's string in an array. You can think like your first index of array will be your first line strings.

I have .txt file with some lines:
qqqq
wwww
weee
errrr
rttttt
yyyyy
uuuu
How to create a loop that will read each line in file, put it to clipboard and finally paste it to any form.
I have tried many variant, but my macros always read the whole file, not the each line.

My source data is a large .txt file. However, I have noticed there are issues with the format of some of the data, with some lines truncated and the remainder of the line dropping to the line below. The break always appears to be at the same point (after the invoice number) but there doesn't appear to be any logic as to which line gets truncated.

This is a different from someone else's similarly-titled question. Neither Excel nor OpenOffice allow users to specify line delimiters, so I'm trying to replace semi-colons with line breaks. How do I edit the code of a text file?

You can add line breaks from the Find/Replace function in Word 2010 - make your CSV a .txt and go to town. Under Find/Replace click the "More >>" button and then the special drop down box to insert a line break as a replacement for ":"

I tried and succeeded doing it in Notepad++ which is a free application for Windows offered on Github. Please download install Notepad++ and copy paste your text with the ; semicolons that need to be replaced with a "carriage return" or "new line".

Highlight the entire text and press Ctrl + F, it will launch a popup called Find. Click on the Replace tab and type in your semicolon into the Find what slot, and type \r\n into the Replace with slot. Note you must click on the Regular expression button to highlight it. Then press the Replace All button.

If it does not work the problem is with the "semicolon" you typed into the Find what slot. Highlight any "Semicolon" in the text you want to replace and copy-paste that semicolon into the Find what. Proceed as before with the replacement steps. I had to do this twice as my text had some odd Unicode based semicolons that were not related to my PC keyboard strokes.

Well, it seems that your problem is related to how you update your line rather than to file writing. Basically WriteLine adds a end-of-line character at the end of the string before writing it to the file, so in my opinion you are not preparing correctly the string to write down. How are you updating the line?

My use for this is to import the .txt file into excel and populate the spreadsheet to mirror what was shown in the schedule in Revit. But because the .txt has no line breaks, the cell which contains all the text from the multi-line parameter, shows as a single string of text with no breaks.

I have attached an example, however this isn't an issue with this particular file, it is an enquiry regarding this feature in general which occurs in any project I do. Please see '-Furniture Schedule Export' Schedule. This is the schedule I use to export to a .txt file, then import into excel, but always have the issue of the 'description' field loosing line breaks.

I've never tried dynamo before - maybe if I have time to learn this would be useful. Any plug-ins I have found to export schedules to excel, miss the function of exporting shared parameters, which are key for me. Unless you know of any which do that?

You can place the schedule on a sheet, print to PDF, and convert from PDF, open the PDF in Adobe or Bluebeam and save as Excel format. The downside is everything becomes text so if you need SUM or other calculations, it can be bothersome.

Then using System.IO.File.ReadAllLines("test.txt").Length will be sufficient. This counts the number of rows in each text file accurately. If there is question from your requester around this, let them know about the wraparound feature of text readers. Sometimes what is visible in a reader is not indicative of how the file is actually structured.

For some reason, my data keeps exporting with a LR end line character instead of a CR LF end line character. I have no idea if this can be fixed during the output in SAS but if it can that'd be great.

If you are running SAS on Unix then the default will be to use linefeed ('0A'x) as the end of line character. If you are running on Windows then the default will be CRLF ('0D0A'x) instead. You can use the TERMSTR= option on the FILENAME or FILE statement to control that.

But if you do feel a need to use PROC EXPORT instead then you will need add a FILENAME statement to define a fileref. You will then reference the fileref in the PROC EXPORT statement instead of the raw physical filename. That way you have a place to put the TERMSTR= option.

Your comment was helpful in getting my file encoded with windows CRLF, but i'm noticing that it is causing many of the variables in my file to get dropped/removed. The code I use is exactly as you show, but also using encoding= 'UTF-8' and options nobomfile as I need the file to be encoded in utf-8. Happy to share more info if needed.

Is the problem that you values are too long for the default 32K record length? If so then add the LRECL= option to the FILENAME statement to set something longer. In general you can have any length then , but memory limits on particular operating systems might limit you to 10000000 bytes max for LRECL setting. Which should be way longer than any reasonable dataset would require.

Make sure that File.txt is the correct file name and that it is in the same directory as your script. If the file is located in a different directory, then you will need to provide the full path to the file.

In this example, the sed command is used to remove any line containing the string "example" from the file "example.txt". The modified file is saved as "temp.txt", and then the original file is replaced with the modified file using the mv command.

This did work for me! The issue I believe is that I didn't create a temp text file. Also needed to include the entire location of the file and it worked as expected. Really appreciate the help on this one, thank you!

Jamf's purpose is to simplify work by helping organizations manage and secure an Apple experience that end users love and organizations trust. Jamf is the only company in the world that provides a complete management and security solution for an Apple-first environment that is enterprise secure, consumer simple and protects personal privacy. Learn about Jamf.

This site contains User Content submitted by Jamf Nation community members. Jamf does not review User Content submitted by members or other third parties before it is posted. All content on Jamf Nation is for informational purposes only. Information and posts may be out of date when you view them. Jamf is not responsible for, nor assumes any liability for any User Content or other third-party content appearing on Jamf Nation.

I just started using Julia and I cant seem to figure out how to write to .txt or .inp properly. I need to create a list with different compounds on different lines on .txt. I tried working with the normal text file handling and with delimitedfiles.
The export always look like this>

It is working now. I didnt`t know the file would keep the newlines even though it wasnt showing when I opened the notepad. My bad. I just ran the cosmotherm application and it created the proper input from the txt file I created with Julia.

The example mentioned uses the 2nd parameter in FileRedLine() for no good reason. As I mentioned previous, it is not good and it will get slower and slower as each line is read as AutoIt needs to start from the 1st line again to count to the given line.

How can you use this script to paste line by line to another application, such as Notepad, where you paste one line of presses enter, and then moves to the next until the there will be no text for pasting.

Hi Mhz,

First of All, thanks for your valuable response.. You were absolutely right on understanding my query

And the code you provided was very much useful to me. Now I am able to save the values in .ini file and achieve my expected o/p.

I dont want to stop with only using this code, but I would like to clarify a small doubt so that I can understand better.

Are you sure? Your history in this forum shows something different ....no?
... and also not sure why you felt the need tp resurrect an 7 years old thread for making this statement .... not very smart I think assuming you might need help in the future.

7fc3f7cf58
Reply all
Reply to author
Forward
0 new messages