Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
create multiple .cfg files
#1
#######I am trying to create multiple .cfg files. I need a new file every time the string apCode changes. Currently, it will spit out 1 file. Also, the file that it spits out shows to be .cfg but the device that is supposed to accept the file, does not recognize it.#####






######################################## User Input #########################################################################
import time
tName = input ("What is the Name of the Tower?--->")
antType = input ("What Type of Antennas are Being Used?--->")
numAps = int(input ("How Many APs are Going on the Tower?--->"))
gateWay = input ("Enter the Gateway for the APs--->")
notused = input ("Press Enter to Continue--->")
apCode = (0)

########################################AP Information#######################################################################

apIp = (gateWay[:-1]+"10")
apAzmath = int(360 / numAps)
apDirection = ("%03d" % apCode)
fileName = (tName +"-"+ apDirection)
apConfig = ("""the config goes here""")

######################################## File Writing ###########################################################################
while apCode < (numAps * apAzmath - apAzmath):
f = open (fileName+".cfg","w+")
f.write (apConfig.format(apIp,antType,apDirection,tName,gateWay,tName,antType,apDirection,tName,antType,apDirection,tName))
f.close ()
time.sleep (2)
apCode = (apCode + apAzmath)



I am 4 days into learning Python. I am sure that there are things in here that will make you guys cringe. Sorry
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python convert multiple files to multiple lists MCL169 6 1,602 Nov-25-2023, 05:31 AM
Last Post: Iqratech
  splitting file into multiple files by searching for string AlphaInc 2 917 Jul-01-2023, 10:35 PM
Last Post: Pedroski55
  Create new folders and copy files cocobolli 3 1,508 Mar-22-2023, 10:23 AM
Last Post: Gribouillis
  Merging multiple csv files with same X,Y,Z in each Auz_Pete 3 1,204 Feb-21-2023, 04:21 AM
Last Post: Auz_Pete
  unittest generates multiple files for each of my test case, how do I change to 1 file zsousa 0 978 Feb-15-2023, 05:34 PM
Last Post: zsousa
  Find duplicate files in multiple directories Pavel_47 9 3,166 Dec-27-2022, 04:47 PM
Last Post: deanhystad
  Create multiple/single csv file for each sql records mg24 6 1,435 Sep-29-2022, 08:06 AM
Last Post: buran
  Extract parts of multiple log-files and put it in a dataframe hasiro 4 2,107 Apr-27-2022, 12:44 PM
Last Post: hasiro
  Search multiple CSV files for a string or strings cubangt 7 8,111 Feb-23-2022, 12:53 AM
Last Post: Pedroski55
  Rename part of filename in multiple files atomxkai 7 7,400 Feb-18-2022, 10:03 PM
Last Post: atomxkai

Forum Jump:

User Panel Messages

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