Python Forum
how do I format json data in splunk?
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how do I format json data in splunk?
#11
I took out try except clause, but I'm still getting same error message back.

this line of code does not seem to be working "reader = results.ResultsReader(response)"

I'm importing from splunklib.results import *, not sure why i'm getting this error.




Traceback (most recent call last):
    reader = results.ResultsReader(response)
NameError: global name 'results' is not defined
Reply
#12
What is results? You don't define it anywhere, you only try to use methods on it. Is it maybe a module you didn't import?
Reply
#13
It's not the same error, it's happening earlier now, the variable changed. As nilamo said, it wasn't ever defined (unlike the first one, which would have been defined if the second was and everything else went well)>
Reply
#14
no, its the same variable "reader" below are my imports I posted earlier

import requests
import csv
#import urllib.request
import json
import sys
try: from splunklib.results import *
except: print(sys.exc_info())
try: import httplib
except: print(sys.exc_info())
try: import urllib
except: print(sys.exc_info())
Reply
#15
Why the try/except/print-sys-blah-blah? It seems like that just reduces information and then defers (guaranteed) failures. Stop doing this, it makes it harder for us to help you and... for you to help you.

If you remove these, let your program fail as early as possible, and for the purposes of moving forward ignore every single line after the failure, just focus on solving that first failure. If no problems pop up after, deal with them as they come.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  encrypt data in json file help jacksfrustration 1 66 Yesterday, 05:16 PM
Last Post: deanhystad
  Export data from PDF as tabular format zinho 5 646 Nov-11-2023, 08:23 AM
Last Post: Pedroski55
  format json outputs ! evilcode1 3 1,692 Oct-29-2023, 01:30 PM
Last Post: omemoe277
  How to properly format rows and columns in excel data from parsed .txt blocks jh67 7 1,802 Dec-12-2022, 08:22 PM
Last Post: jh67
  Read nested data from JSON - Getting an error marlonbown 5 1,310 Nov-23-2022, 03:51 PM
Last Post: snippsat
  Convert Json to table format python_student 2 5,070 Sep-28-2022, 12:48 PM
Last Post: python_student
  Reading Data from JSON tpolim008 2 1,032 Sep-27-2022, 06:34 PM
Last Post: Larz60+
  Issue in changing data format (2 bytes) into a 16 bit data. GiggsB 11 2,560 Jul-25-2022, 03:19 PM
Last Post: deanhystad
  Converting cells in excel to JSON format desmondtay 4 1,686 May-23-2022, 10:31 AM
Last Post: Larz60+
  Convert nested sample json api data into csv in python shantanu97 3 2,726 May-21-2022, 01:30 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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