Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6946095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:31:14+00:00 2026-05-27T13:31:14+00:00

arr = [(line.rstrip(‘\n’).split(‘;’)) for line in open(‘C:/Config_Changer.csv’)] import sys import fileinput for i, line

  • 0
arr = [(line.rstrip('\n').split(';')) for line in open('C:/Config_Changer.csv')]
import sys
import fileinput
for i, line in enumerate(fileinput.input('C:/1.cfg', inplace = 1)):
    sys.stdout.write(line.replace(arr[0][0], arr[0][1]))

Hey all,

I wrote the above lines so it’s working fine but its replacing only ary[0][0], so i want to loop it as like below,so first dimention is needed to loop.Can anyone help me with the loop commands.Where should I have to put loop exactly ???

sys.stdout.write(line.replace(arr[a][0], arr[a][1]))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:31:15+00:00Added an answer on May 27, 2026 at 1:31 pm

    so what you want is to apply all the replacements that are in arr to the line: (unlike aix’s answer, this one avoids the explicit indexing)

    for i, line in enumerate(fileinput.input('C:/1.cfg', inplace = 1)):
        for f,t in arr:
            line = line.replace(f, t)
        sys.stdout.write(line)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

f = open('transaction.log','r') ClerkHash = dict() arr = [0,0] for line in f: Tdate
I have a Perl application that takes from command line an input as: application
In my iPhone app, I'm reading a csv file. The relevant line is this:
dpkg --list |grep linux-image |grep ii | while read line do arr=(${line}) let i=i+1
var buttons =$('input[type=button]'); var arr = (buttons).makeArray; for(i=0;i <= arr.length ; i++ ) {
arr = [[NSMutableArray alloc]init]; [arr addObject:[NSNumber numberWithInt:4]]; [arr addObject:[NSNumber numberWithInt:45]]; [arr addObject:[NSNumber numberWithInt:23]]; [arr
arr = [red,green,yellow] arr2 = arr.clone arr2[0].replace(blue) puts arr.inspect puts arr2.inspect produces: [blue, green,
int arr[ 5 ] = { 0 }; int i = 8; // out
I have an array ( arr ) of elements, and a function ( f
function get_arr($arr) { unset($arr[0]); } $arr1 = array(1,2); $arr2 = array(1,2); get_arr(&$arr1); get_arr($arr2); echo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.