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 8903355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:51:01+00:00 2026-06-15T01:51:01+00:00

I am attempting to create a bar plot of a large text file of

  • 0

I am attempting to create a bar plot of a large text file of data that looks like the following, storedd in a csv file:

#DowntonPBS, 23
#DowntonAbbey, 12
#Download, 8
#Download:, 2
#Downloads, 2
#DownstairsMixtape, 1
#DownWithAssad, 1
#DownYoTLParty, 1
#DowntonAbbey?, 1
#Downtonabbey, 1
#DowntownAbbey, 1

The following code is where I’m at, and while this method has worked in the past for different plotting scripts, I’ve done something wrong here that I just can’t seem to find. Instead of plotting all of the data, I only seem to be getting three records.

import pylab as p                                                                                                                                                       
import sys                                                                                                                                                              
from matplotlib.mlab import csv2rec                                                                                                                                     

y = []                                                                                                                                                                  

fig = p.figure()                                                                                                                                                        
ax = fig.add_subplot(1,1,1)                                                                                                                                             

input = open(sys.argv[1], 'r')                                                                                                                                          

data = csv2rec(input, names=['tag', 'count'])                                                                                                                           

for item in data['count']:
        y.append(item)

N = len(y)

ind = range(N)

ax.bar(ind, y, align='center')

ax.set_ylabel('Counts')

ax.set_title('HashTag Diversity')

ax.set_xticks(ind)

group_labels = data['tag']

ax.set_xticklabels(group_labels)

fig.autofmt_xdate()

p.show()

If I add print statements for y and N, and run the script against my larger dataset I end up with:

[45, 37, 36]
3

These values should be a very large array “1000” values and the lenth (N) should = 1000. I’m not sure what’s going on here.

  • 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-06-15T01:51:02+00:00Added an answer on June 15, 2026 at 1:51 am

    csv2rec() will ignore lines startswith “#” by default, you can change this by:

    csv2rec(input, names=['tag', 'count'], comments="something")      
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to create a table for monitoring purposes using the following script: $w3wppriv
I am attempting to create a report, utilizing a matrix, that only displays columns
I'm attempting to create a single Controller class to handle all foreseeable surveys that
Climbing the learning mountain of TVirtualTreeView, I'm attempting to create a custom descendant that
I am attempting to create a regex that will match all uppercase letters before
Attempting to create an itemgroup for use in a target where the file types
I am attempting to create a custom server control CollapsablePanel that extends ASP.net's Panel.
I am attempting to create an app where there is a tab bar on
Im attempting to re-create the following layout seen in the screenshot below. I wanted
I'm attempting to create a class that extends a CursorAdapter in order to display

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.