Removing an index number from a list/csv using input - python-3.x

i'm doing an exercise for school where you use python to store client details in a csv and i'm having trouble with adding a way for the user to delete their client details as pop won't accept anything but an index number - can someone help me find a way to do this? I'm really new to coding sorry.
Here's my code:
if first_name in name:
for x in range(0,len(existing_clients)):
if first_name == existing_clients[x][0]:
print(existing_clients[x])
index = existing_clients.index(existing_clients[x])
print(index)
existing_clients.pop(index)
The above works to print out the index number but I don't know how to make it delete the client details from the list/csv. I feel like i'm missing something really obvious and stupid.
Here's an example of the csv data making up existing_clients:
Ave,O' Hogan,Ms,Male,13/04/2022,Help Desk Operator,1285.66,64.80
Ariel,Fidge,Honorable,Female,15/09/2022,VP Quality Control,8.27,82.63
Timoteo,McGowing,Dr,Male,03/12/2021,General Manager,1751.11,23.92
Lezley,Wilmott,Mr,Male,04/07/2022,Statistician I,350.05,74.83

Related

Get a Steam key from a txt file then move it to another

I'm currently working on a Steam bot project that trades Steam items for Game keys. I'm already done with all the trading part, and the only part missing now is the part where the script actually looks for a key in my txt file. (one key per line)
I have a variable ready called totalKeyWeGive that outputs 1 , 2 , 3 etc depending on how many keys is the user buying.
So now I want to 1. get 1 , 2 , 3 etc keys from my file, then move these used keys to another file.
How can I do that ?
this is the part that I need to modify (everything is working) :
offer.accept(offer);
console.log("OFFER ACCEPTED");
//loop on how much we give the key
//get steamkey from file here ------
}
var textMsg = "Hello ! You bought "+totalKeyWeGive+ " Game keys. Your keys are: "
}
client.chatMessage(offer.partner.getSteamID64(), textMsg);
Thanks to everyone who will take the time to read this post. It's kinda messy, sorry about that :/
Not sure how the keys are organized in the txt file, but assuming they are one per line you could do something like this: https://stackoverflow.com/a/38843461/4686055
That is, before removing the line, save it in memory and write it to the target file.
Send an interval to slice() to remove multiple lines. Check this out for an example of how it works: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
Hope this helps!
Update: an alternative approach could be to use the readlines module instead of reading the entire file into memory: https://nodejs.org/api/readline.html#readline_example_read_file_stream_line_by_line

If certain thing is included in input use anything after it

Hello I am currently working on a script that goes onto a website and automatically adds an Item to cart and purchases it for you I have a script that works except the only problem is that It is only able to checkout a single Item Item. Here is an example fo the script:
Item_code = input('Item code: ')
Size = input('Size: ')
def BOT():
driver = webdriver.Chrome(executable path=
URL = .....
driver.get(URL)
while True:
try:
driver.find_element_by_css_selector(Item_code).click()
break
except NoSuchElementException:
driver.refresh()
select = Select(driver.find_element_by_id('s'))
select.select_by_visible_text(Size)
The script finds the item with the item code that I use and then selects the size from the users choice
I want to be able to write the code and the size but If I want to bot to cart two Items in different sizes I want it to type in a , and insert the next Item code and Size For example:
12345, 6789
Large, Medium
I want to somehow write that if a comma is included to read and use the code after it after it uses the first one and repeat that for every comma so If I wanted to get 3 or even 4 all I would have to do is this:
1234, 5678, 7890, etc...
Large, medium, Small, etc...
If anyone could Help me out I would really appreciate it I was thinking of something like
for , in BOT():
(something like this but Im not sure )
I know how to tell the script that if Item_code == (',') then do this but that would not work because it needs to be just the comma and I do not know how to tell it to repeat the BOT() a second time and use the second code and size
If someone could help me out I would really appreciate it thanks.
(I want to be able to share this bot since I have already made a GUI for it and all that)
(not sure if the executable path will work when sharing)
I have fixed this problem I created several custom functions and called them on special if statements
ex.
if Item.count(',') == (1):
Cart1()
Checkout()
etc.....

Pysnow - How to do an update record by based on something other than by only text-value?

I have the following problem.
I've written a program on Python to be run on a web-page which enters records into ServiceNow. I work in a help desk and for example automating password resets would be a huge help. I can create these records through Pysnow-module for Python and everything else works fine, but I can only enter values (like Configuration Item) only based on their text-name. This is a problem because many values have different companies, billing etc. and they have the same name, so my queries end up for random companies. User could be from company A, timecard for company X, item for company E and so on.
When i fetch a record with a certain field:
Command: r.get_one(fields=['u_configuration_item'])
I get this as response:
{'link': 'https://xxxxx.service
now.com/api/now/table/core_company/f7a9a64430b070c8e017981c4ba7a0e7',
'value': 'f7a9a64430b070c8e017981c4ba7a0e7'}
When i try for example make a dictionary out of the response:
dict = {'value': 'xxx', 'link': 'xxx'}
'u_configuration_item': dict
It doesn't give me an error, but just makes a record with blank field.
The following kind of code works fine, but it's just this 'Random Value' comes with a company/billing which is not right for the customer.
s = pysnow.Client(instance='xxxx', user='xxxx',password='xxxx')
result = r.update({'u_configuration_item': 'Random Value'})
print(result['number'])
I've tried googling, entering different kinds of info, but just can't get forward.
I found an answer, i though i had tried this before, but just by replacing "Random value" with sys_id which is unique to every single record it works. I'm happy i was persistent though and keep trying, almost was about to give up.

Netsuite - Transfer Inventory error

I have been using NetSuite for only a short time, and already hate it. I am sorry if this is a stupid question, but I haven't been able to find an answer so far, either in the Netsuite docs, StackOverflow or other websites. In fact, the answers I found have resulted in an error.
My company requires a script to transfer inventory based on an EDI input file. Reading the file is no problem, even parsing it is working. However, actually inserting the data is proving problematic.
I have been able to insert normal records, but Inventory Transfer records are giving me problems.
From Stack Overflow I found and adapted some code into the following:
var xfer = nlapiCreateRecord("inventorytransfer");
xfer.setFieldValue("trandate", FormatDate("20160101"));
xfer.setFieldValue("location", 9);
xfer.setFieldValue("transferlocation", 9);
nlapiSelectNewLineItem('invt');
nlapiSetLineItemValue("invt","invtid",1, 189);
nlapiSetLineItemValue("invt","adjustqtyby", 1, "5");
nlapiCommitLineItem('invt');
var id = nlapiSubmitRecord(xfer);
The FormatDate function just exchanges the date from the text file into a system date NetSuite can understand.
However, when I run this code I get the following error:
USER_ERROR: You must enter at least one line item for this transaction.
I thought inserting the line item was the reason to use nlapiSelectNewLineItem, but I guess not. Also nlapiCreateNewLineItem doesn't seem to exist.
The values I am inserting are all just test data, as I'm testing this in the debugger. Location 9 exists, as does item 189.
My full script finds these id's based on string values from the text files. But since this is the section that doesn't work I have set it apart to test.
Can anyone help with this?
You did not specify the type of script you are using, but, looks like you are not setting the fields on the record object, but, setting the value on current record. Below, is the suggested code.
Also, there is no sublist named invt, it should be inventory. Also, there is no field as such invtid, I think most probably you want to setup item, the field Id should be item. You might want to refer SuiteScript Record Browser as well for a help on correct Ids
var xfer = nlapiCreateRecord("inventorytransfer");
xfer.setFieldValue("trandate", FormatDate("20160101"));
xfer.setFieldValue("location", 9);
xfer.setFieldValue("transferlocation", 9);
xfer.selectNewLineItem('inventory');
xfer.setCurrentLineItemValue("inventory", "item", 189);
xfer.setCurrentLineItemValue("inventory","adjustqtyby", "5");
xfer.commitLineItem('inventory');
var id = nlapiSubmitRecord(xfer);
If you are using Bin/Lot Numbered Items, please see help topic "Sample Scripts for Advanced Bin / Numbered Inventory Management"

Drop an Index from SQL Server by Object ID

Using SQL Server 2012 and I have somehow ended up w/ an index named:
<Name of Missing Index, sysname,>
I'm not sure how or when it happened. I've tried dropping this index using:
DROP INDEX EMAIL_ADDRESS.<Name of Missing Index, sysname,>
It won't of course since I receive the expected error message:
Incorrect syntax near '<'.
Querying the DMV in SQL Server tells me I should drop this index so it's even more frustrating that I cannot. This has been one of those little things that has gnawed at me for a few years now. I've looked for answers a few times now over the years. I've probably poured 4 hours into finding a way to drop an index by something other than name. Nothing.
Can someone help me? Running this query:
SELECT * FROM SYS.INDEXES WHERE NAME = '<Name of Missing Index, sysname,>'
Produces an OBJECT_ID of 281104092. Is there a way to drop the object using this ID? There must be, right? Am I just stuck w/ this crazy index forever?
Try to delete with Database Owner Name. It worked for me.
DROP INDEX ccl2.[TBL_HamdunSoft].[<Name of Missing Index, sysname,>]
Or
DROP INDEX dbo.[TBL_HamdunSoft].[<Name of Missing Index, sysname,>]

Resources