Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Mapped Strings
#10
(Sep-03-2023, 05:43 PM)Skaperen Wrote: you have code or you intend to have code. if you have learned enough you can at least try to make code. if you show us what you have tried (even if it immediately fails) we might get some idea of what you are thinking or what you need to change so it goes on to the next step.

i do not understand your description of what you are trying to do.

Ok, I will explain better

I have converted may csv file in a list with the code below

csv_file_path = '/Users/ecosta/Downloads/values.csv'

with open(csv_file_path, 'r') as file:
    csv_reader = csv.reader(file)
    data_list = []
    for row in csv_reader:
        data_list.append(row)

for row in data_list:
    print(row)

The result is:
['nre', 'echoRequests']
['nrbrc', 'n3BearerResourceCommand']
['nrcn', 'n3ChangeNotificationRequest']
['nrrc', 'n3ContextRsp']
['nrcit', 'n3CreateIndirectDataFwdTunnel']
['nrcs', 'n3CreateSessRequest']
['nrdbc', 'n3DeleteBearerCommand']
['nrdit', 'n3DeleteIndirectDataFwdTunnel']
['nrds', 'n3DeleteSessRequest']
['nri', 'n3Identification']

in the @Larz60+ code we have the below:
def testit():
    buf = "-nrrc 3 -trac 3 -nrds 2 -trds 5 -nrcs 2 -nrmb 2 -trmb 2 -nrrab 2 " \
        "-trrab 1-nri 3 -tri 3 -nrfr 2 -trfr 7 -nfrc 2 -tfrc 1 -nfac 2 " \
        "-tfac 1 -nrca 2 -trca 1 -nrdbc 2 -trdbc 4 -nrmbc 2 -trmbc 4 -era on " \
        "-nre 5 -tre 120 -trsl 24 -nrcn 1 -trcn 4 -nrpc 2 -trpc 7 -tnsc 10 " \
        "-nns 2 -tas 1 -nnr 2 -tar 1 -nnsc 2 -tasc 1 -pb off -sncr off " \
        "-trer 1 -eras off -nres 3 -tres 3000 -eris 60 -trcs 5000 -eriss 60 " \
        "-nress 3 -tress 3 -eram off -erim 60 -nrem 3 -trem 3 -trgl 1 " \
        "-trcss 4000 -trdss 2 -trmbs 2 -trmbcs 4 -nrcss 2 -nrdss 3 -nrmbs 2 " \
        "-nrmbcs 2 -mmbr off -mabr on -nrmab 2 -trmab 2 -trml 24 -nbsig on " \
        "-rnccpe true -rnccsi true -dnd 0 -hfipe false -nrcit 2 -trcit 2 " \
        "-nrdit 2 -trdit 2 -tdit 6 -tavac 2 -scn false -nrbrc 2 -nrbrcs 2 " \
        "-trbrc 4000 -trbrcs 4000 -gpfcl 72,73,78,83,84,86,91,100,113,120 " \
        "-rlm off -atrc 10 -sots off"
     
    newstring = replace_text(buf, replace_this='nrdbc', with_this='n3DeleteBearerCommand')
    print(newstring)
I would like to use the csv converted in list to pass the first string in "replace_this" and the second string in "with_this"

I think I have explained better.

Thanks guys
Reply


Messages In This Thread
Python Mapped Strings - by edualfaia - Aug-30-2023, 04:25 PM
RE: Python Mapped Strings - by Larz60+ - Aug-30-2023, 06:16 PM
RE: Python Mapped Strings - by edualfaia - Aug-30-2023, 10:12 PM
RE: Python Mapped Strings - by edualfaia - Aug-30-2023, 11:21 PM
RE: Python Mapped Strings - by Larz60+ - Aug-31-2023, 03:01 AM
RE: Python Mapped Strings - by edualfaia - Aug-31-2023, 07:45 AM
RE: Python Mapped Strings - by Larz60+ - Aug-31-2023, 10:01 PM
RE: Python Mapped Strings - by edualfaia - Sep-01-2023, 10:15 AM
RE: Python Mapped Strings - by Skaperen - Sep-03-2023, 05:43 PM
RE: Python Mapped Strings - by edualfaia - Sep-03-2023, 09:43 PM
RE: Python Mapped Strings - by edualfaia - Sep-03-2023, 10:22 PM
RE: Python Mapped Strings - by Skaperen - Sep-04-2023, 01:48 AM
RE: Python Mapped Strings - by snippsat - Sep-04-2023, 11:08 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  print a list strings is fast but printing the joined strings is slow Skaperen 9 4,119 Aug-26-2019, 07:48 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020